Question

I have the following in my .htaccess file, which I do often for cleaner URL's. There are pro's and cons to this I know and I think I've found a con.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options All -Indexes

I've up a new cPanel account for this website so the URL looks like this:

http://www.example.com/~newuser/

...where example.com is my reseller account and newuser is my client.

The site loads fine but when I click a link http://www.example.com/~newuser/about I get the following error:

The requested URL /home/newuser/public_html/about.php was not found on this server.

The problem is, that's exactly the file I want it to display and that is the document root. Any ideas?

Thanks in advance.

Was it helpful?

Solution

Before your RewriteCond lines, add a RewriteBase line like so:

RewriteEngine on
RewriteBase /~newuser/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options All -Indexes
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top