Solved

modify .htaccess

Posted on 2014-12-10
8
143 Views
Last Modified: 2014-12-11
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.
0
Comment
Question by:Kinderly Wade
  • 3
  • 3
  • 2
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40492886
Bit confused...
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]
0
 

Author Comment

by:Kinderly Wade
ID: 40492916
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.
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40492927
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 58

Expert Comment

by:Gary
ID: 40492932
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

???
0
 

Author Comment

by:Kinderly Wade
ID: 40493291
Hi Gary,

You are absolutely correct! I need to redirect the page and each page will not show .php extension.
0
 
LVL 14

Expert Comment

by:Edwin Hoffer
ID: 40493301
Hello Kinderly,

To hide .php extension use the below code in .haccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Open in new window


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

Open in new window


Thanks
Edwin
0
 

Author Comment

by:Kinderly Wade
ID: 40493375
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
0
 
LVL 14

Expert Comment

by:Edwin Hoffer
ID: 40493406
Sure :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question