Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

Thanks

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.

5 Answers 5

   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

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 Anthony 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

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
    
Please do not add the same answer twice. You can edit your existing answers. Please remove one of your answers. Also please add some description of what does the code do. Thank you. –  pabouk Dec 13 '13 at 16:59

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.