Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have a problem with .htaccess mod rewite in godaddy server.

i have .htaccess file like

# Options
Options -Multiviews
Options +FollowSymLinks
RewriteEngine on
RewriteRule index-hotel_in-(.*)\.htm$ index.php?hotel_in=$1

I have url like http://www.travelsetu.com/index.php?hotelsin=London.

I want url lie http://www.travelsetu.com/hotels-in-london.

what can i do? please help me out.

share|improve this question

migrated from stackoverflow.com Mar 25 '13 at 12:17

This question came from our site for professional and enthusiast programmers.

Your rule will not match because you included the htm extension.

Try using the following code:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^hotels\-in\-(.*)$ index.php?hotelsin=$1 [L,NC]

Please note that you have not fully clarified what the QUERY_STRING should really be. Is it hotel_in or hotelsin? Please amend my code above if it incorrect.

share|improve this answer
    
Hi thanks for qucik responce i add your code in my .htaccess but its giving 500 internal server error. my query string is hotelsin..... – jagu gajjar Mar 25 '13 at 12:22
    
I have edited the code to include escapes for the hyphens. Please give it a try. – Mike Rockett Mar 25 '13 at 13:02
    
Hi,Thanks for your help, now i am getting static url like travelsetu.com/hotels-in-london but the problem is its not reflected on website, i am getting result on travelsetu.com/index.php?hotelsin=London this url too, its not redirecting( i got result using both urls , i want to hide dynamic url), and what can i do to get static url for page 2 (travelsetu.com/index.php?hotelsin=london&page=2) , page 3 (travelsetu.com/index.php?hotelsin=london&page=3) Thanks again for your help...... – jagu gajjar Mar 26 '13 at 7:52
    
And what can i do for my hotel detail page url like this travelsetu.com/… i want url like this travelsetu.com/… Thanks a lot..... – jagu gajjar Mar 26 '13 at 7:57

THIS is the right way

Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php [L,QSA]
share|improve this answer
Options +FollowSymLinks -MultiViews -Indexes
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L] 
</IfModule> 

this way worked for me

share|improve this answer
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.travelsetu.com[nc]
RewriteRule ^hotels-in-(.*)$ http://www..travelsetu.com/index.php?hotelsin=$1 [L,nc]

Try this hope this helps

share|improve this answer
1  
This is an incorrect answer. @jagu does not want to redirect, but wants a rewrite so that the URL looks friendly. – Mike Anthony Mar 25 '13 at 11:24
    
Okie.. in that case just remove [r=301,nc] to [L,nc] where [L] tells the server to stop trying to rewrite a URL after it has applied that rule. – Siddhartha Gupta Mar 25 '13 at 11:38
    
Hi thanks for qucik responce i add your code in my .htaccess but its giving 500 internal server error. – jagu gajjar Mar 25 '13 at 12:23
    
Please check if you have AllowOverride set to 'All' or 'FileInfo' in httpd.conf file for having permissions of mod_rewrite directives in .htaccess file. Also add first line : RewriteBase / in .htaccess file – Siddhartha Gupta Mar 25 '13 at 12:29

You must log in to answer this question.

protected by JakeGould Feb 10 at 5:50

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .