Jump to content

htaccess help needed


yoursanjay

Recommended Posts

Hello,I have a dynamic website where all the pages and sections are pulling out from Dynamic URLs like http://www.mysite.com?pageId=5 or http://www.mysite.com?pageId=9There are hundreds of these type of links placed in my site and now I prefer to display static URL in the address bar. For example,If any user click on the link 'http://www.mysite.com?pageId=5', in the address bar the URL it will be converted to 'http://www.mysite.com/service.html' and if clicked on 'http://www.mysite.com?pageId=9', it will be converted to 'http://mysite.com/about,html' and so on.Will it can be done through htaccess file? If so, what should I write in the htaccess file?I can not change the dynamic URLs of my site right now because there are hundreds of links are in my site. Please suggest.

Link to comment
Share on other sites

There are hundreds of these type of links placed in my site and now I prefer to display static URL in the address bar. For example,If any user click on the link 'http://www.mysite.com?pageId=5', in the address bar the URL it will be converted to 'http://www.mysite.com/service.html' and if clicked on 'http://www.mysite.com?pageId=9', it will be converted to 'http://mysite.com/about,html' and so on.Will it can be done through htaccess file? If so, what should I write in the htaccess file?
One of the cardinal rules of URI design is that you shouldn't use file extensions like ".html".This is what your .htaccess might look like:
Options -MultiViewsRewriteEngine OnRewriteRule ^service/?$ /?pageId=5 [L]RewriteRule ^about/?$ /?pageId=9 [L]

(edit: forgot the trailing slashes.)If you really want the .html extension which I don't recommend:

RewriteRule ^service\.html$ /?pageId=9 [L]RewriteRule ^about\.html$ /?pageId=9 [L]

Link to comment
Share on other sites

Thanks for your reply. But it is not working. I have tested in my local server where htaccess supports. The link URL is : http://localhost/sanjay/demo/index.php?pageId=9 and I want to convert the URL in the Address bar as http://localhost/sanjay/demo/service when I click on the dynamic URL.I have tried the following 2 htaccess alternatively but no one works.

Options -Multiviews RewriteEngine On RewriteRule ^sanjay/demo/service$ /?pageId=9 [L]

or

Options -Multiviews RewriteEngine On RewriteRule ^service$ /?pageId=9 [L]

Link to comment
Share on other sites

Thanks for your reply. But it is not working. I have tested in my local server where htaccess supports. The link URL is : http://localhost/sanjay/demo/index.php?pageId=9 and I want to convert the URL in the Address bar as http://localhost/sanjay/demo/service when I click on the dynamic URL.
Ok, well if your .htaccess is in the root directory, use:
Options -MultiViewsRewriteEngine OnRewriteRule ^sanjay/demo/service/?$ /sanjay/demo/index.php?pageId=9 [L]

(edit: just realized I wasn't using the right case for the MultiViews option above)

Link to comment
Share on other sites

Still it is not working. I have put mu .htaccess file inside htdocs/sanjay/demo/ folder and in it written the following code:
Options -MultiViewsRewriteEngine OnRewriteRule ^sanjay/demo/service/?$ /sanjay/demo/index.php?pageId=9 [L]

Have I done any wrong?

I wrote that .htaccess as if it were in the root directory, the directory above "sanjay".
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...