Forum Moderators: phranque

Message Too Old, No Replies

htaccess virtual subdomain question

Problem with subdomains using rewriterule

         

cartuchos

3:30 am on Mar 1, 2007 (gmt 0)

10+ Year Member



Using an example from this site I managed to make the following htaccess file that allows me to convert [website.com...] to
[website.com...]
Everything works perfectly (thanks for the example) but I would like to "loose" the car sub-directory, leaving it as [website.com...]

Here is my current code:

# ****************

# Enable mod_rewrite, start rewrite engine
Options +FollowSymLinks
RewriteEngine on
#
# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^car/([^/]+)/([^/]+)/?$ /detail.php?user=$1&id=$2 [L]
#
# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /detail\.php\?user=([^&]+)&id=([^&]+)\ HTTP/
RewriteRule ^detail\.php$ [website.com...] [R=301,L]

# ****************

My problem is in this line:
RewriteRule ^car/([^/]+)/([^/]+)/?$ /detail.php?user=$1&id=$2 [L]

I was unable to discover how to remove the "car" subdir. Can anyone please help, thanks so much in advance,

regards and best wishes.

jdMorgan

2:01 pm on Mar 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From what I'm reading, it looks like you've conceptualized URL rewriting in reverse. The only way to get rid of "car" is to change the links on your pages. Whether you can do that and still have the information needed by RewriteRule so that it can decide whether to rewrite or not depends on the URL-structure of your site.

I'd suggest reading the following threads from the Apache forum section of the WebmasterWorld library [webmasterworld.com]:

[webmasterworld.com...]
[webmasterworld.com...]
[webmasterworld.com...]

Jim