.htaccess rewrite

can someone help me with an .htaccess rewrite?

i'm trying to convert all requests to "/?spot=8888" to be "/locations/
888".

thanks.

Hi,

Try this .htaccess file:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^\/locations\/(.*)$ /?spot=$1

That didn't work (and appears to be backwards). I tried the following
w/ no luck...

RewriteRule ^\/?spot=(.*)$ /locations/$1
RewriteRule ^\/?spot=(.*)$ /locations/$1 [R=301,L]
RewriteRule /?spot=(.*)$ /locations/$1 [R=301,L]

This is also for a subdomain under Rails...

http://m.domain.com/?spot=8888
to
http://m.domain.com/locations/8888

guys even my problem is somewhat related to the same as currently hosted my application on bluehost which is running on port 12004. so when every i try to access my site “http:///www.mydomain.com” its redirect me to “http://mydomain.com:12004” so if some one guide me that will be very helpful thanks…

regards
abhishek

@abhishek - you can catch all traffic on a port and redirect like this
(but beware of an infinite loop)...

RewriteCond '%{SERVER_PORT}" "^12004$"
RewriteRule "^(.*)$" "http://%{SERVER_NAME}$1" [R=301,L]

Anyone able to help me with a redirect from "/?spot=8888" to "/
locations/8888"? Simple yet elusive :frowning:

Hey thanks sav but still no success…
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
RewriteCond '%{SERVER_PORT}" “^12004$”

RewriteRule “^(.*)$” “http://%{SERVER_NAME}$1” [R=301,L]

This is my .htaccess setting and seriously no idea… wat to do… new in deployment.
Note i don’t have an root access… the only file which i can editi s .htaccess and other files from public folder…

Thanks sav if you can help me

regards
Abhishek Shukla

You probably want to turn on/up rewrite logging for more information
on /why/ you're having "no luck", instead of guessing :slight_smile:

Something like:

RewriteLog "/usr/local/apache-httpd-2.2.9/logs/rewrite.log"
RewriteLogLevel 3

See the httpd docs for more info.

HTH,

Hey Hassan,
Thanks for reply the main issue is that i don’t have an access to apache folder currently my application running on Bluehost with a dedicated IP address. And even i am not able to access rewrite.log file as well :frowning: so that is why my is screwed up… So please guys help me…

Regards
Abhishek shukla

You should be able to set this up through .htaccess with logging
set to go to a directory you have write permissions to.