Michael
Michael

Reputation: 1

URL redirection on Network Solutions host

I am trying to resolve PHP page requests without the .php extension. I would actually prefer URLs without a file extension, but that's not the biggest concern right now. The issue is that outside links are broken with the current configuration:

www.[domainname].com/abc/forms returns the custom 404 page.

www.[domainname].com/abc/forms.php completes correctly.

www.[domainname].com/service resolves to www.[domainname].com.

Requests for www.[domainname].com/abc resolve to the correct index.php and do so without rewriting the URL to www.[domainname].com/abc/index.php.

The directory structure is roughly like this:

Here's my htaccess file. The second block should take any request for a file that would be a valid file if it were a .php file, and append the ".php" extension. It does not do this. The third block is my attempt to force the request for the forms.php page for the most commonly occurring error. This doesn't work, but the following line does work (mentioned above.) Finally, custom 404 page is working.

Options -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[domainname].com [NC]
RewriteRule ^(.*)$ http://www.[domainname].com/$1 [L,R=301]


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php


RewriteRule ^abc/forms$ /abc/forms.php [L,R=301]

RewriteRule ^service(.*)$ / [L,R=301]
ErrorDocument 404 /404.php

Am I missing something here? Thanks.

Upvotes: 0

Views: 490

Answers (1)

Raul Leaño Martinet
Raul Leaño Martinet

Reputation: 2113

I believe that RewriteBase is needed, like so:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

Upvotes: 1

Related Questions