cardi777
cardi777

Reputation: 563

htaccess 404 issue

I am working with a CMS, and up until today its been fine.

But i have discovered that the mod rewirte only works if the website is in the root directory. If I put the entire CMS into a folder, i get a 404.

Please help!

RewriteEngine on
Options +FollowSymLinks

RewriteRule ^([^/\.]+)/?$ /index.php?1=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?1=$1&2=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?1=$1&2=$2&3=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?1=$1&2=$2&3=$3&4=$4 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?1=$1&2=$2&3=$3&4=$4&5=$5 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?1=$1&2=$2&3=$3&4=$4&5=$5&6=$6 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?1=$1&2=$2&3=$3&4=$4&5=$5&6=$6&7=$7 [L]

Upvotes: 0

Views: 76

Answers (2)

Kyborek
Kyborek

Reputation: 1511

Your script is extracting data that are between slashes like:

/test1/test2/ transfers into /index.php?1=test1&2=test2

but since you started using folder it works like:

/folder/test1/test2/ transfers into /index.php?1=folder&2=test1&3=test2

so the folder name is breaking your structure, you will need to fix every line with folder name or expression like this:

RewriteRule ^[^/\.]+/([^/\.]+)/?$ /folder/index.php?1=$1 [L]

So you will need to fix both regular expression and new path on every line, just replace folder with name of your folder and add [^/\.]+/ at start

If that doesnt work you may just need to fix regular expression only without adding /folder to the second part of line

Upvotes: 0

Mattias
Mattias

Reputation: 9481

Then you need to add the subfolder to your rewrite rule like this, for all of your rules.

RewriteRule ^([^/\.]+)/?$ /subfolder/index.php?1=$1 [L]

With your configuration apache will search for the index.php file in the root directory

Upvotes: 1

Related Questions