Ron
Ron

Reputation: 4095

.htaccess rewrite rules works in sub-folder but not in the main

I got some rewriterules which work at folder inside the main for example: main folder is / i put htaccess inside /

this is the .htaccess

Options +FollowSymlinks
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^about/(.*)/$ $1.php [L]
RewriteRule ^(.*)/download/(.*)/(.*)/(.*)/$ download-donate.php?product=$1&version=$2&os=$3&method=$4 [L]
RewriteRule ^(.*)/download/(.*)/$ download.php?product=$1&version=$2 [L]
RewriteRule ^subscribe/(.*)/$ subscribe-$1.php [L]
RewriteRule ^subscribe/(.*)/(.*)/$ subscribe-$1.php?email=$2 [L]
RewriteRule ^(.*)/screenshots/$ screenshots.php?product=$1 [L]
RewriteRule ^(.*)/(.*)/$ products.php?product=$1&page=$2 [L]
RewriteRule ^schedule-manager/$ products.php?product=schedule-manager&page=view [L]
RewriteRule ^visual-command-line/$ products.php?product=visual-command-line&page=view [L]
RewriteRule ^windows-hider/$ products.php?product=windows-hider&page=view [L]
RewriteRule ^(.*)/$ $1.php [L]

it doesnt work in the main folder. if I put the same htaccess (changing the RewriteBase to /test/) and i put it inside folder called "test" > /test/ it works perefectly - both main and test folders got same files exactly!

Thanks

Upvotes: 0

Views: 571

Answers (2)

yoda
yoda

Reputation: 10981

Try changing the order of this 2 parameters :

RewriteEngine On
RewriteBase /

Not sure it would do anything, but it makes more sense this way.

edit

This assumes you have your code over /test/ folder.

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^about/(.*)/$ test/$1.php [L]
RewriteRule ^(.*)/download/(.*)/(.*)/(.*)/$ test/download-donate.php?product=$1&version=$2&os=$3&method=$4 [L]
RewriteRule ^(.*)/download/(.*)/$ test/download.php?product=$1&version=$2 [L]
RewriteRule ^subscribe/(.*)/$ test/subscribe-$1.php [L]
RewriteRule ^subscribe/(.*)/(.*)/$ test/subscribe-$1.php?email=$2 [L]
RewriteRule ^(.*)/screenshots/$ test/screenshots.php?product=$1 [L]
RewriteRule ^(.*)/(.*)/$ test/products.php?product=$1&page=$2 [L]
RewriteRule ^schedule-manager/$ test/products.php?product=schedule-manager&page=view [L]
RewriteRule ^visual-command-line/$ test/products.php?product=visual-command-line&page=view [L]
RewriteRule ^windows-hider/$ test/products.php?product=windows-hider&page=view [L]
RewriteRule ^(.*)/$ test/$1.php [L]

Upvotes: 0

dinbrca
dinbrca

Reputation: 1107

If your hosting company is GoDaddy, add

Options -MultiViews

above the

Options +FollowSymlinks

Upvotes: 2

Related Questions