Reputation: 257
I am editing a website for a client and have hit a bit of a roadblock. I can edit and publish existing pages just fine, but if I were to create a new .php
or .html
page and try to view it online, I get sent to the 404 error page. I can take the new page I want and rename it to overwrite an existing page and everything loads fine.
I have tried some different ways to do the rules I need, but they either try to find the page in the root (When it's actually in /application/views/
); or it works and I have the same problem as before.
I need help making a new .htaccess
file that allows you to go to website.com/signup
and it takes you to /application/views/signup.php
. Below are some examples of what I've tried so far.
Original .htaccess
:
RewriteEngine on
RewriteCond $1
!^(index\.php|images|css|js|uploads|db|fonts|blogger|support|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Another version that has the same issue.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php/$1 [L]
Lastly, a version that allows new pages to be viewed but looks for them in the root folder. Eg. The requested URL /signup.php
was not found on this server. I imagine if this is modified it will work, but I have no experience with .htaccess
rules. Much appreciated to anyone that can help me and future browsers!
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteRule ^([^\.]+)$ $1.htm [NC,L]
Upvotes: 1
Views: 42
Reputation: 45914
You should be able to add a couple of conditions (RewriteCond
directives) to the original .htaccess
file rule:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|uploads|db|fonts|blogger|support|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
So, only if the request does not map to an actual file or directory will it be rewritten (to the front controller).
Upvotes: 1