Hi Everyone,
I want to redirect friendly URLs to Actual URLs.
Friendly URL - http://example.com/phone-devices
Actual URL - http://example.com/servlet/CS?pagename=phone
I want to write the redirect rules for the following 2 requirements
1. http://example.com/phone-devices should be rewritten to http://example.com/servlet/CS?pagename=phone by apache [Internal Redirection Required]. Friendly URL should be retained in the browser. Please find below the rewrite rule which i have written for this requirement
# Part 1
RewriteCond %{HTTP_HOST} example.com
RewriteRule ^/phone\-devices/?$ /servlet/CS?pagename=phone [R,P,L]
The above working fine.
2. http://example.com/servlet/CS?pagename=phone should be redirected to http://example.com/phone-devices in the user's browser so that this friendly URL will again use the Part 1 rewrite rule to get the page from the server and to maintain the friendly URL in the browser. The rewrite rules which i have written for this requirement are
# Part 2
RewriteCond %{QUERY_STRING} pagename=phone
RewriteRule ^/servlet/CS http://example.com/phone-devices/? [R]
When I am putting the above two in the httpd.conf file, it starts looping between the URLs. Could anyone please tell whether the above requirements are possible? please tell where i made mistake?