Kinderly Wade
asked on
modify .htaccess
Dear experts,
I wish to know some concept about htaccess file.
I've tried this code but doesn't work for removing the .php extension:
Options +FollowSymlinks
RewriteEngine on
Redirect /index.html /App/views/login.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
I was able to redirect but unable to strip the .php extension
Thanks.
I wish to know some concept about htaccess file.
I've tried this code but doesn't work for removing the .php extension:
Options +FollowSymlinks
RewriteEngine on
Redirect /index.html /App/views/login.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
I was able to redirect but unable to strip the .php extension
Thanks.
ASKER
Hi Gary,
I am new to the Rewrite syntax. I am not sure if I am doing it correctly. THanks
If there is a reference page on rewriteCond or rewriteRule that will be great.
I am new to the Rewrite syntax. I am not sure if I am doing it correctly. THanks
If there is a reference page on rewriteCond or rewriteRule that will be great.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think you are wanting to remove the .php extension from any incoming links and do a 301
Then all (extensionless) links should point to the php page
???
Then all (extensionless) links should point to the php page
???
ASKER
Hi Gary,
You are absolutely correct! I need to redirect the page and each page will not show .php extension.
You are absolutely correct! I need to redirect the page and each page will not show .php extension.
Hello Kinderly,
To hide .php extension use the below code in .haccess file:
and for redirection Redirect /index.html /App/views/login.php to Redirect /index.html /App/views/login, use the below code:
Thanks
Edwin
To hide .php extension use the below code in .haccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
and for redirection Redirect /index.html /App/views/login.php to Redirect /index.html /App/views/login, use the below code:
Redirect /index.html /App/views/login
Thanks
Edwin
ASKER
Hi Edwin,
THanks for the reply. I will use the code for now and I will also definitely look up the regular expression to see if I can adjust with other redirect rules as well. Thanks again
THanks for the reply. I will use the code for now and I will also definitely look up the regular expression to see if I can adjust with other redirect rules as well. Thanks again
Sure :)
You are trying to link to php files without using the .php extension?
Change
Redirect /index.html /App/views/login.php
to
Redirect /index.html /App/views/login
Your rewrite should only be doing the rewrite if the filename minus .php doesn't exist.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]