Another Beginners Conundrum

New to mod_rewrite? This is a good place to start.

Another Beginners Conundrum

Postby WillB » Tue Jul 28, 2009 7:21 am

Hi, I've been fooling around with Mod_Rewrite, but can't quite get it to do what I want it to do.

I'm either getting 500 errors, or the page isn't directing itself where I want it to go.

Basically, I have a subfolder within which I'd like to contain the .htaccess file, with the mod-rewrite rule only affecting links to this folder.

I'd like: www.mydomain.co.uk/mysubfolder/mypage
to redirect to: www.mydomain.co.uk/mysubfolder/index.ph ... ink=mypage

I know it's going to end up being a really simple solution, but it's not cooperating with me.

Thanks for any help I receive, this website seems to be a great, newb friendly website.
WillB
 
Posts: 2
Joined: Tue Jul 28, 2009 7:14 am

Postby richardk » Tue Jul 28, 2009 3:26 pm

Basically, I have a subfolder within which I'd like to contain the .htaccess file, with the mod-rewrite rule only affecting links to this folder.

By putting a .htaccess file in a directory it will only affect that directory (and sub directories of that directory).

Something like
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Don't match existing files.
RewriteCond %{SCRIPT_FILENAME} !-f
# Don't match existing directories.
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ ./index.php?permalink=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby WillB » Wed Jul 29, 2009 12:29 am

Thanks a lot! I'm sure I tried that yesterday, but worked like a charm this time.
WillB
 
Posts: 2
Joined: Tue Jul 28, 2009 7:14 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 27 guests

cron