: RewriteEngine On showing Apache test page I have centos 7 and I need to put this .htaccess file inside one of my directories (www/html/forum) in order to display friendly URLs so instead of
I have centos 7 and I need to put this .htaccess file inside one of my directories (www/html/forum) in order to display friendly URLs so instead of looking like example.com/index.php?user=222 it would look like example.com/user/222.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .(jpeg|jpg|gif|png)$ /public/404.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This worked fine back on my old centos 6.8 but on 7 all it does is to display the Apache test page and all directories and files inside forum show as forbidden. Why is that?
UPDATE: /www/html/forum is the document root and the site is accessed by a "parked domain" (example.com).
More posts by @Dunderdale272
1 Comments
Sorted by latest first Latest Oldest Best
UPDATE: The assumptions made here are wrong so this answer is mostly irrelevant now. This answer is just for future reference.
We're going to have to make some assumptions to answer this...
/www/html is your document root and therefore /forum is a subdirectory, off the document root in which this .htaccess file is located.
All requests should be relative to the /forum subdirectory. (Which I assume is why this .htaccess file is in the /forum subdirectory.)
Try changing your directives to the following:
RewriteEngine On
RewriteBase /forum
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .(jpeg|jpg|gif|png)$ public/404.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Note that I've changed the RewriteBase directive and made both RewriteRule substitutions relative (ie. no slash prefix).
instead of looking like example.com/index.php?user=222 it would look like example.com/user/222.
I'm assuming that everything is in the /forum subdirectory, so this would need to be present in both these URLs: example.com/forum/index.php?user=222 and example.com/forum/user/222 respectively. You would only be able to remove the /forum subdirectory from the URL if this .htaccess file was in the document root. (If a request of the form example.com/index.php?user=222 worked successfully then "something else" is going on here.)
This worked fine back on my old centos 6.8 but on 7 all it does is to display the Apache test page
I don't really see how this could have worked on your "old centos 6.8", unless you had a different directory structure and this was all in the document root and not a subdirectory?
I can only assume that the "Apache text page" is index.php in the document root? Otherwise, where is this located?
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.