Mod rewrite directory trouble

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Mod rewrite directory trouble

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you need to specify the path to pages.php if you move it outside the root..
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Yea.. make it part of your rewrite rule.
Post Reply