Page 1 of 1

Mod rewrite directory trouble

Posted: Sat Sep 15, 2007 9:19 am
by kkonline
When i use the code it works fine if i store pages.php in /public_html (mysite.com/pages.php) on the server BUT i get Page Not Found 404 error when i place the pages.php in a directory like mysite.com/directory/pages.php.

What to do in order that mode rewrite works independent of the directory i place pages.php in?

I am using the following code in my .htaccess file

Code: Select all

Options +FollowSymLinks

RewriteEngine On

RewriteRule ^pages/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)(/*)$ pages.php?sid=$1&catid=$2&page=$3&mode=$4&tcheck=$5

RewriteRule ^pages/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ pages.php?sid=$1&catid=$2&page=$3&mode=$4&tcheck=$5
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.

Posted: Sat Sep 15, 2007 11:13 am
by John Cartwright
you need to specify the path to pages.php if you move it outside the root..

Posted: Sat Sep 15, 2007 11:25 am
by kkonline
Jcart wrote:you need to specify the path to pages.php if you move it outside the root..
So that means if i have mysite.com/dir1/pages.php

Code: Select all

RewriteRule ^dir1/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)(/*)$ dir1/pages.php?sid=$1&catid=$2&page=$3&mode=$4&tcheck=$5
if i have mysite.com/dir3/pages.php

Code: Select all

RewriteRule ^dir3/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)(/*)$ dir3/pages.php?sid=$1&catid=$2&page=$3&mode=$4&tcheck=$5
Is there any automatic way of writing the same thing again and again with just change of dir1 or dir 2 etc?

Posted: Sat Sep 15, 2007 11:29 am
by John Cartwright
Yea.. make it part of your rewrite rule.