Solved

modify .htaccess

Posted on 2014-12-10
8
145 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video teaches users how to migrate an existing Wordpress website to a new domain.

740 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