Solved

modify .htaccess

Posted on 2014-12-10
8
138 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 12

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 12

Expert Comment

by:Edwin Hoffer
ID: 40493406
Sure :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now