Forum Moderators: phranque

Message Too Old, No Replies

How to rewrite Variables to subdirectories?

variables, subdirectory, sub directory, htaccess

         

ShaunG

6:10 pm on Mar 1, 2009 (gmt 0)

10+ Year Member



Can someone give me a hand here as I am not familiar with htaccess at all. I need the htaccess code so I can use variables in my links as sub directories.

ie. [domain.com...]

I want to be able to use this url with the following link:

[domain.com...]

Thank you in advance for anyone that can help.

g1smd

6:13 pm on Mar 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This rewrite question came up three times in the last few days.

Check recent threads for examples already posted and post your best effort code back here.

ShaunG

7:05 pm on Mar 1, 2009 (gmt 0)

10+ Year Member



Yes I have looked at others but they seem to be similar but a little different and since i know nothing about .htaccess other then where to put the rules, I'm not sure what minor changes need to be made. Sorry!

ShaunG

8:15 pm on Mar 1, 2009 (gmt 0)

10+ Year Member



This was the best i could find and looks similar but can this be used if ?kw= will be a dynamic variable?

# Externally redirect direct HTTP client requests for dynamic URL to static URL
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /module\.php\?([^&]+&)*page=Help&?
RewriteRule ^module\.php$ http://www.example.com/Help? [R=301,L]
#
# Internally rewrite static URL requests to the module.php script
RewriteRule ^Help$ /module.php?page=Help [L]

[edited by: eelixduppy at 8:19 pm (utc) on Mar. 1, 2009]
[edit reason] disabled smileys [/edit]

ShaunG

9:48 pm on Mar 1, 2009 (gmt 0)

10+ Year Member



Ok, I'll post a reply to my own question to help others since I got it to work...

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/ [domain.com...] [NC]

g1smd

12:03 am on Mar 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



With a rewrite, omit the domain name from the target URL.

That is, the target should be an internal filepath, not another URL.

By including a domain name, the code you have posted in your last post is for a 302 redirect, not a rewrite.

Add [L] to the end of the rule.

See also: [webmasterworld.com...]