how to remove .php extension using htaccess on godaddy linux hosting Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Come Celebrate our 10 Year Anniversary!Enable php extension within .htaccessHow to 301 redirect a single file or directory on a GoDaddy shared Windows hosting plan?.htaccess mod_rewrite remove .php extension, but preserve URL pathmod_rewrite remove trailing slash is causing loopsHtaccess regex working strange.htaccess redirect all extension to phprewrite rule does not rewrite url as expectedGodaddy .htaccess and mod_urlhtaccess: Remove PHP extension only for specific files or folder.htaccess remove php file extension not working only on heroku
What does the black goddess statue do and what is it?
Why is arima in R one time step off?
Marquee sign letters
/bin/ls sorts differently than just ls
Protagonist's race is hidden - should I reveal it?
`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY
Why did Europeans not widely domesticate foxes?
Processing ADC conversion result: DMA vs Processor Registers
Is it appropriate to mention a relatable company blog post when you're asked about the company?
RIP Packet Format
Did war bonds have better investment alternatives during WWII?
Why do people think Winterfell crypts is the safest place for women, children & old people?
Are these square matrices always diagonalisable?
Is there an efficient way for synchronising audio events real-time with LEDs using an MCU?
Will I be more secure with my own router behind my ISP's router?
What to do with someone that cheated their way though university and a PhD program?
What is ls Largest Number Formed by only moving two sticks in 508?
Are there existing rules/lore for MTG planeswalkers?
How can I wire a 9-position switch so that each position turns on one more LED than the one before?
Does using the Inspiration rules for character defects encourage My Guy Syndrome?
Does Prince Arnaud cause someone holding the Princess to lose?
How would it unbalance gameplay to rule that Weapon Master allows for picking a fighting style?
Coin Game with infinite paradox
Why is water being consumed when my shutoff valve is closed?
how to remove .php extension using htaccess on godaddy linux hosting
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Come Celebrate our 10 Year Anniversary!Enable php extension within .htaccessHow to 301 redirect a single file or directory on a GoDaddy shared Windows hosting plan?.htaccess mod_rewrite remove .php extension, but preserve URL pathmod_rewrite remove trailing slash is causing loopsHtaccess regex working strange.htaccess redirect all extension to phprewrite rule does not rewrite url as expectedGodaddy .htaccess and mod_urlhtaccess: Remove PHP extension only for specific files or folder.htaccess remove php file extension not working only on heroku
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
How to remove .php
extension using .htaccess
file. I have tried many examples without success. An Internal server error is regularly showing. I am using Godaddy Linux Hosting.
This code is the latest which I am using.
<IfModule mod_rewrite.c>
Options All -Indexes
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Unless directory, remove trailing slash
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^([^/]+)/$ http://a.sprybirds.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %THE_REQUEST ^(.+).php([#?][^ ]*)? HTTP/
RewriteRule ^(.+).php$ http://a.sprybirds.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
</IfModule>
Site is parked on a sub-domain http://subdomain.example.com
and folder sequence is just like web-root/sub_folder/site_folder/
.
linux php .htaccess apache-2.4 godaddy
add a comment |
How to remove .php
extension using .htaccess
file. I have tried many examples without success. An Internal server error is regularly showing. I am using Godaddy Linux Hosting.
This code is the latest which I am using.
<IfModule mod_rewrite.c>
Options All -Indexes
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Unless directory, remove trailing slash
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^([^/]+)/$ http://a.sprybirds.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %THE_REQUEST ^(.+).php([#?][^ ]*)? HTTP/
RewriteRule ^(.+).php$ http://a.sprybirds.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
</IfModule>
Site is parked on a sub-domain http://subdomain.example.com
and folder sequence is just like web-root/sub_folder/site_folder/
.
linux php .htaccess apache-2.4 godaddy
What does your error log say? If it's throwing a 500 Internal, there's some kind of cause and the logfile should give you more detail about why that is.
– ldennison
Jun 28 '15 at 7:28
Can#
occur in a request at all?
– Hagen von Eitzen
Jun 28 '15 at 13:48
if you are using godaddy, linux shared hosting, than try this article, it will get you the results.kvcodes.com/2016/02/godaddy-remove-php-extension
– Kvvaradha
Feb 17 '16 at 10:30
add a comment |
How to remove .php
extension using .htaccess
file. I have tried many examples without success. An Internal server error is regularly showing. I am using Godaddy Linux Hosting.
This code is the latest which I am using.
<IfModule mod_rewrite.c>
Options All -Indexes
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Unless directory, remove trailing slash
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^([^/]+)/$ http://a.sprybirds.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %THE_REQUEST ^(.+).php([#?][^ ]*)? HTTP/
RewriteRule ^(.+).php$ http://a.sprybirds.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
</IfModule>
Site is parked on a sub-domain http://subdomain.example.com
and folder sequence is just like web-root/sub_folder/site_folder/
.
linux php .htaccess apache-2.4 godaddy
How to remove .php
extension using .htaccess
file. I have tried many examples without success. An Internal server error is regularly showing. I am using Godaddy Linux Hosting.
This code is the latest which I am using.
<IfModule mod_rewrite.c>
Options All -Indexes
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Unless directory, remove trailing slash
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^([^/]+)/$ http://a.sprybirds.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %THE_REQUEST ^(.+).php([#?][^ ]*)? HTTP/
RewriteRule ^(.+).php$ http://a.sprybirds.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
</IfModule>
Site is parked on a sub-domain http://subdomain.example.com
and folder sequence is just like web-root/sub_folder/site_folder/
.
linux php .htaccess apache-2.4 godaddy
linux php .htaccess apache-2.4 godaddy
edited Oct 15 '18 at 14:24
MrWhite
6,43421426
6,43421426
asked Jun 28 '15 at 6:40
Kunwar Asif Ali KhanKunwar Asif Ali Khan
1113
1113
What does your error log say? If it's throwing a 500 Internal, there's some kind of cause and the logfile should give you more detail about why that is.
– ldennison
Jun 28 '15 at 7:28
Can#
occur in a request at all?
– Hagen von Eitzen
Jun 28 '15 at 13:48
if you are using godaddy, linux shared hosting, than try this article, it will get you the results.kvcodes.com/2016/02/godaddy-remove-php-extension
– Kvvaradha
Feb 17 '16 at 10:30
add a comment |
What does your error log say? If it's throwing a 500 Internal, there's some kind of cause and the logfile should give you more detail about why that is.
– ldennison
Jun 28 '15 at 7:28
Can#
occur in a request at all?
– Hagen von Eitzen
Jun 28 '15 at 13:48
if you are using godaddy, linux shared hosting, than try this article, it will get you the results.kvcodes.com/2016/02/godaddy-remove-php-extension
– Kvvaradha
Feb 17 '16 at 10:30
What does your error log say? If it's throwing a 500 Internal, there's some kind of cause and the logfile should give you more detail about why that is.
– ldennison
Jun 28 '15 at 7:28
What does your error log say? If it's throwing a 500 Internal, there's some kind of cause and the logfile should give you more detail about why that is.
– ldennison
Jun 28 '15 at 7:28
Can
#
occur in a request at all?– Hagen von Eitzen
Jun 28 '15 at 13:48
Can
#
occur in a request at all?– Hagen von Eitzen
Jun 28 '15 at 13:48
if you are using godaddy, linux shared hosting, than try this article, it will get you the results.kvcodes.com/2016/02/godaddy-remove-php-extension
– Kvvaradha
Feb 17 '16 at 10:30
if you are using godaddy, linux shared hosting, than try this article, it will get you the results.kvcodes.com/2016/02/godaddy-remove-php-extension
– Kvvaradha
Feb 17 '16 at 10:30
add a comment |
2 Answers
2
active
oldest
votes
The question is missing example URLs, which is really essential for diagnosing such problems, however...
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
This only matches URLs with single path segments, ie. URLs that are effectively in the document root, eg. /foo
. It won't match URLs with multiple path segments, ie. URLs that are effectively in subdirectories eg. /foo/bar
- which would explain why you are getting 404s for "php files inside the subfolder".
You need to remove the slash in the RewriteRule
pattern, in order to match any URL depth:
RewriteRule ^([^.]+)$ $1.php [L]
By including a slash in the negated character class you are only matching URLs that don't contain a slash. ie. URLs in the document root only.
(There is no need to backslash escape a literal dot when used inside a character class.)
add a comment |
Do you have a .htaccess file in ./public_html/? If so, what's inside it? The way .htaccess works is by giving the directory closest to the actual root top priority.
As an example:
/home/username/public_html/.htaccess
is given a higher priority (i.e. more control) than
/home/username/public_html/sub_directory/.htaccess
If you're primary .htaccess
file is setting rules one way and the sub-directory is setting them another, it's possible you'll run in to issues (i.e. an error).
If you're set in your actual web root, the following lines could be causing some issues as cPanel allows server administrators to set these options by default from within WHM. If these are already set (specifically -Indexes), you'll likely see an error.
Options All -Indexes
Options +FollowSymLinks -MultiViews
Note: The -Indexes
directive is normally set by default before clients are even placed on a server (or it should be, unless there's a specific reason not to), FYI. This is more of a security recommendation to prevent directory browsing as not every client is going to know that unless there's an index.[ext]
file in every directory, their directories are wide-open for browsing by whoever wants to take a look.
If removing those resolves the error, then you've found the problem :). If removing these lines does not work, trial & error is where we need to start.
Back to the top, look in directories that reside above the directory you're having issues with. Check the .htaccess files and make sure you have "display or show hidden files" checked or set to "yes" in the S/FTP program that you're using as they're not always visible by default.
From here, the best course of action would be to backup each .htaccess file and re-add them one-by-one until you run in to another error. This way you can mark down which file upload brought on the error and we can take a look at that one.
Update #01
Since the culprit for the error most likely was indeed the -Indexes
, you can add the following back to the .htaccess
file:
Options +FollowSymLinks -MultiViews
If that does not resolve the 404, try this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Adds Trailing Slash to the URI as long as it's not for a
# file.
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_URI !(.[a-zA-Z0-9]1,5|/|#(.*))$
RewriteRule ^(.*)$ http://subdomain.example.com/$1/ [R=301,L]
# Checks to make sure the request is a directory.
# Checks to see if the request matches a file with a .php ext.
# If all is well, push the request through to the matching file.
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^([^.]+)/$ http://subdomain.example.com/$1.php
I have a multi domain hosting plan. my primary website is hosted in web-root folder and a htaccess file is also placed in this we-root. And my site a.sprybirds.com is hosted in this web-root folder in sequence of folders web-root/sub_folder/site_folder . And I have another htaccess file in this site folder site_folder. I have provided the code in my is of htaccess file inside site_folder.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:28
@KunwarAsifAliKhan did you try removing the two lines as noted above? If so, did the error persist? Ideally, those two lines should be removed from all .htaccess files while troubleshooting. You can test whether or not you actually need -Indexes. Simply create an empty directory anywhere and access it. If you can browse it, then GoDaddy doesn't have this option enabled (although they really should...). If you can't browse, then this option isn't needed.
– Jonathan
Jun 28 '15 at 11:34
i have removed the above two line from htaccess file and my site is not showing internal sever error but another pages like a.sprybirds.com/business-search?find=food-beverage showing 404 error. I have used this htaccess to remove php extension and I have removed .php from all urls of my website.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:47
@KunwarAsifAliKhan Please see the modified post above. I've added an example I've used which worked on the last Apache 2.x server I was working on.
– Jonathan
Jun 28 '15 at 12:51
I have just paste the code that you have provided in my htaccess file. But I am still facing the problem 404 error when I not use .php but site with .php extension is working check url a.sprybirds.com/business-search.php?find=food-beverage
– Kunwar Asif Ali Khan
Jun 28 '15 at 13:21
|
show 2 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f702119%2fhow-to-remove-php-extension-using-htaccess-on-godaddy-linux-hosting%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The question is missing example URLs, which is really essential for diagnosing such problems, however...
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
This only matches URLs with single path segments, ie. URLs that are effectively in the document root, eg. /foo
. It won't match URLs with multiple path segments, ie. URLs that are effectively in subdirectories eg. /foo/bar
- which would explain why you are getting 404s for "php files inside the subfolder".
You need to remove the slash in the RewriteRule
pattern, in order to match any URL depth:
RewriteRule ^([^.]+)$ $1.php [L]
By including a slash in the negated character class you are only matching URLs that don't contain a slash. ie. URLs in the document root only.
(There is no need to backslash escape a literal dot when used inside a character class.)
add a comment |
The question is missing example URLs, which is really essential for diagnosing such problems, however...
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
This only matches URLs with single path segments, ie. URLs that are effectively in the document root, eg. /foo
. It won't match URLs with multiple path segments, ie. URLs that are effectively in subdirectories eg. /foo/bar
- which would explain why you are getting 404s for "php files inside the subfolder".
You need to remove the slash in the RewriteRule
pattern, in order to match any URL depth:
RewriteRule ^([^.]+)$ $1.php [L]
By including a slash in the negated character class you are only matching URLs that don't contain a slash. ie. URLs in the document root only.
(There is no need to backslash escape a literal dot when used inside a character class.)
add a comment |
The question is missing example URLs, which is really essential for diagnosing such problems, however...
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
This only matches URLs with single path segments, ie. URLs that are effectively in the document root, eg. /foo
. It won't match URLs with multiple path segments, ie. URLs that are effectively in subdirectories eg. /foo/bar
- which would explain why you are getting 404s for "php files inside the subfolder".
You need to remove the slash in the RewriteRule
pattern, in order to match any URL depth:
RewriteRule ^([^.]+)$ $1.php [L]
By including a slash in the negated character class you are only matching URLs that don't contain a slash. ie. URLs in the document root only.
(There is no need to backslash escape a literal dot when used inside a character class.)
The question is missing example URLs, which is really essential for diagnosing such problems, however...
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
This only matches URLs with single path segments, ie. URLs that are effectively in the document root, eg. /foo
. It won't match URLs with multiple path segments, ie. URLs that are effectively in subdirectories eg. /foo/bar
- which would explain why you are getting 404s for "php files inside the subfolder".
You need to remove the slash in the RewriteRule
pattern, in order to match any URL depth:
RewriteRule ^([^.]+)$ $1.php [L]
By including a slash in the negated character class you are only matching URLs that don't contain a slash. ie. URLs in the document root only.
(There is no need to backslash escape a literal dot when used inside a character class.)
answered Oct 15 '18 at 14:22
MrWhiteMrWhite
6,43421426
6,43421426
add a comment |
add a comment |
Do you have a .htaccess file in ./public_html/? If so, what's inside it? The way .htaccess works is by giving the directory closest to the actual root top priority.
As an example:
/home/username/public_html/.htaccess
is given a higher priority (i.e. more control) than
/home/username/public_html/sub_directory/.htaccess
If you're primary .htaccess
file is setting rules one way and the sub-directory is setting them another, it's possible you'll run in to issues (i.e. an error).
If you're set in your actual web root, the following lines could be causing some issues as cPanel allows server administrators to set these options by default from within WHM. If these are already set (specifically -Indexes), you'll likely see an error.
Options All -Indexes
Options +FollowSymLinks -MultiViews
Note: The -Indexes
directive is normally set by default before clients are even placed on a server (or it should be, unless there's a specific reason not to), FYI. This is more of a security recommendation to prevent directory browsing as not every client is going to know that unless there's an index.[ext]
file in every directory, their directories are wide-open for browsing by whoever wants to take a look.
If removing those resolves the error, then you've found the problem :). If removing these lines does not work, trial & error is where we need to start.
Back to the top, look in directories that reside above the directory you're having issues with. Check the .htaccess files and make sure you have "display or show hidden files" checked or set to "yes" in the S/FTP program that you're using as they're not always visible by default.
From here, the best course of action would be to backup each .htaccess file and re-add them one-by-one until you run in to another error. This way you can mark down which file upload brought on the error and we can take a look at that one.
Update #01
Since the culprit for the error most likely was indeed the -Indexes
, you can add the following back to the .htaccess
file:
Options +FollowSymLinks -MultiViews
If that does not resolve the 404, try this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Adds Trailing Slash to the URI as long as it's not for a
# file.
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_URI !(.[a-zA-Z0-9]1,5|/|#(.*))$
RewriteRule ^(.*)$ http://subdomain.example.com/$1/ [R=301,L]
# Checks to make sure the request is a directory.
# Checks to see if the request matches a file with a .php ext.
# If all is well, push the request through to the matching file.
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^([^.]+)/$ http://subdomain.example.com/$1.php
I have a multi domain hosting plan. my primary website is hosted in web-root folder and a htaccess file is also placed in this we-root. And my site a.sprybirds.com is hosted in this web-root folder in sequence of folders web-root/sub_folder/site_folder . And I have another htaccess file in this site folder site_folder. I have provided the code in my is of htaccess file inside site_folder.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:28
@KunwarAsifAliKhan did you try removing the two lines as noted above? If so, did the error persist? Ideally, those two lines should be removed from all .htaccess files while troubleshooting. You can test whether or not you actually need -Indexes. Simply create an empty directory anywhere and access it. If you can browse it, then GoDaddy doesn't have this option enabled (although they really should...). If you can't browse, then this option isn't needed.
– Jonathan
Jun 28 '15 at 11:34
i have removed the above two line from htaccess file and my site is not showing internal sever error but another pages like a.sprybirds.com/business-search?find=food-beverage showing 404 error. I have used this htaccess to remove php extension and I have removed .php from all urls of my website.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:47
@KunwarAsifAliKhan Please see the modified post above. I've added an example I've used which worked on the last Apache 2.x server I was working on.
– Jonathan
Jun 28 '15 at 12:51
I have just paste the code that you have provided in my htaccess file. But I am still facing the problem 404 error when I not use .php but site with .php extension is working check url a.sprybirds.com/business-search.php?find=food-beverage
– Kunwar Asif Ali Khan
Jun 28 '15 at 13:21
|
show 2 more comments
Do you have a .htaccess file in ./public_html/? If so, what's inside it? The way .htaccess works is by giving the directory closest to the actual root top priority.
As an example:
/home/username/public_html/.htaccess
is given a higher priority (i.e. more control) than
/home/username/public_html/sub_directory/.htaccess
If you're primary .htaccess
file is setting rules one way and the sub-directory is setting them another, it's possible you'll run in to issues (i.e. an error).
If you're set in your actual web root, the following lines could be causing some issues as cPanel allows server administrators to set these options by default from within WHM. If these are already set (specifically -Indexes), you'll likely see an error.
Options All -Indexes
Options +FollowSymLinks -MultiViews
Note: The -Indexes
directive is normally set by default before clients are even placed on a server (or it should be, unless there's a specific reason not to), FYI. This is more of a security recommendation to prevent directory browsing as not every client is going to know that unless there's an index.[ext]
file in every directory, their directories are wide-open for browsing by whoever wants to take a look.
If removing those resolves the error, then you've found the problem :). If removing these lines does not work, trial & error is where we need to start.
Back to the top, look in directories that reside above the directory you're having issues with. Check the .htaccess files and make sure you have "display or show hidden files" checked or set to "yes" in the S/FTP program that you're using as they're not always visible by default.
From here, the best course of action would be to backup each .htaccess file and re-add them one-by-one until you run in to another error. This way you can mark down which file upload brought on the error and we can take a look at that one.
Update #01
Since the culprit for the error most likely was indeed the -Indexes
, you can add the following back to the .htaccess
file:
Options +FollowSymLinks -MultiViews
If that does not resolve the 404, try this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Adds Trailing Slash to the URI as long as it's not for a
# file.
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_URI !(.[a-zA-Z0-9]1,5|/|#(.*))$
RewriteRule ^(.*)$ http://subdomain.example.com/$1/ [R=301,L]
# Checks to make sure the request is a directory.
# Checks to see if the request matches a file with a .php ext.
# If all is well, push the request through to the matching file.
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^([^.]+)/$ http://subdomain.example.com/$1.php
I have a multi domain hosting plan. my primary website is hosted in web-root folder and a htaccess file is also placed in this we-root. And my site a.sprybirds.com is hosted in this web-root folder in sequence of folders web-root/sub_folder/site_folder . And I have another htaccess file in this site folder site_folder. I have provided the code in my is of htaccess file inside site_folder.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:28
@KunwarAsifAliKhan did you try removing the two lines as noted above? If so, did the error persist? Ideally, those two lines should be removed from all .htaccess files while troubleshooting. You can test whether or not you actually need -Indexes. Simply create an empty directory anywhere and access it. If you can browse it, then GoDaddy doesn't have this option enabled (although they really should...). If you can't browse, then this option isn't needed.
– Jonathan
Jun 28 '15 at 11:34
i have removed the above two line from htaccess file and my site is not showing internal sever error but another pages like a.sprybirds.com/business-search?find=food-beverage showing 404 error. I have used this htaccess to remove php extension and I have removed .php from all urls of my website.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:47
@KunwarAsifAliKhan Please see the modified post above. I've added an example I've used which worked on the last Apache 2.x server I was working on.
– Jonathan
Jun 28 '15 at 12:51
I have just paste the code that you have provided in my htaccess file. But I am still facing the problem 404 error when I not use .php but site with .php extension is working check url a.sprybirds.com/business-search.php?find=food-beverage
– Kunwar Asif Ali Khan
Jun 28 '15 at 13:21
|
show 2 more comments
Do you have a .htaccess file in ./public_html/? If so, what's inside it? The way .htaccess works is by giving the directory closest to the actual root top priority.
As an example:
/home/username/public_html/.htaccess
is given a higher priority (i.e. more control) than
/home/username/public_html/sub_directory/.htaccess
If you're primary .htaccess
file is setting rules one way and the sub-directory is setting them another, it's possible you'll run in to issues (i.e. an error).
If you're set in your actual web root, the following lines could be causing some issues as cPanel allows server administrators to set these options by default from within WHM. If these are already set (specifically -Indexes), you'll likely see an error.
Options All -Indexes
Options +FollowSymLinks -MultiViews
Note: The -Indexes
directive is normally set by default before clients are even placed on a server (or it should be, unless there's a specific reason not to), FYI. This is more of a security recommendation to prevent directory browsing as not every client is going to know that unless there's an index.[ext]
file in every directory, their directories are wide-open for browsing by whoever wants to take a look.
If removing those resolves the error, then you've found the problem :). If removing these lines does not work, trial & error is where we need to start.
Back to the top, look in directories that reside above the directory you're having issues with. Check the .htaccess files and make sure you have "display or show hidden files" checked or set to "yes" in the S/FTP program that you're using as they're not always visible by default.
From here, the best course of action would be to backup each .htaccess file and re-add them one-by-one until you run in to another error. This way you can mark down which file upload brought on the error and we can take a look at that one.
Update #01
Since the culprit for the error most likely was indeed the -Indexes
, you can add the following back to the .htaccess
file:
Options +FollowSymLinks -MultiViews
If that does not resolve the 404, try this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Adds Trailing Slash to the URI as long as it's not for a
# file.
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_URI !(.[a-zA-Z0-9]1,5|/|#(.*))$
RewriteRule ^(.*)$ http://subdomain.example.com/$1/ [R=301,L]
# Checks to make sure the request is a directory.
# Checks to see if the request matches a file with a .php ext.
# If all is well, push the request through to the matching file.
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^([^.]+)/$ http://subdomain.example.com/$1.php
Do you have a .htaccess file in ./public_html/? If so, what's inside it? The way .htaccess works is by giving the directory closest to the actual root top priority.
As an example:
/home/username/public_html/.htaccess
is given a higher priority (i.e. more control) than
/home/username/public_html/sub_directory/.htaccess
If you're primary .htaccess
file is setting rules one way and the sub-directory is setting them another, it's possible you'll run in to issues (i.e. an error).
If you're set in your actual web root, the following lines could be causing some issues as cPanel allows server administrators to set these options by default from within WHM. If these are already set (specifically -Indexes), you'll likely see an error.
Options All -Indexes
Options +FollowSymLinks -MultiViews
Note: The -Indexes
directive is normally set by default before clients are even placed on a server (or it should be, unless there's a specific reason not to), FYI. This is more of a security recommendation to prevent directory browsing as not every client is going to know that unless there's an index.[ext]
file in every directory, their directories are wide-open for browsing by whoever wants to take a look.
If removing those resolves the error, then you've found the problem :). If removing these lines does not work, trial & error is where we need to start.
Back to the top, look in directories that reside above the directory you're having issues with. Check the .htaccess files and make sure you have "display or show hidden files" checked or set to "yes" in the S/FTP program that you're using as they're not always visible by default.
From here, the best course of action would be to backup each .htaccess file and re-add them one-by-one until you run in to another error. This way you can mark down which file upload brought on the error and we can take a look at that one.
Update #01
Since the culprit for the error most likely was indeed the -Indexes
, you can add the following back to the .htaccess
file:
Options +FollowSymLinks -MultiViews
If that does not resolve the 404, try this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Adds Trailing Slash to the URI as long as it's not for a
# file.
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_URI !(.[a-zA-Z0-9]1,5|/|#(.*))$
RewriteRule ^(.*)$ http://subdomain.example.com/$1/ [R=301,L]
# Checks to make sure the request is a directory.
# Checks to see if the request matches a file with a .php ext.
# If all is well, push the request through to the matching file.
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^([^.]+)/$ http://subdomain.example.com/$1.php
edited Oct 15 '18 at 14:26
MrWhite
6,43421426
6,43421426
answered Jun 28 '15 at 10:59
JonathanJonathan
112
112
I have a multi domain hosting plan. my primary website is hosted in web-root folder and a htaccess file is also placed in this we-root. And my site a.sprybirds.com is hosted in this web-root folder in sequence of folders web-root/sub_folder/site_folder . And I have another htaccess file in this site folder site_folder. I have provided the code in my is of htaccess file inside site_folder.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:28
@KunwarAsifAliKhan did you try removing the two lines as noted above? If so, did the error persist? Ideally, those two lines should be removed from all .htaccess files while troubleshooting. You can test whether or not you actually need -Indexes. Simply create an empty directory anywhere and access it. If you can browse it, then GoDaddy doesn't have this option enabled (although they really should...). If you can't browse, then this option isn't needed.
– Jonathan
Jun 28 '15 at 11:34
i have removed the above two line from htaccess file and my site is not showing internal sever error but another pages like a.sprybirds.com/business-search?find=food-beverage showing 404 error. I have used this htaccess to remove php extension and I have removed .php from all urls of my website.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:47
@KunwarAsifAliKhan Please see the modified post above. I've added an example I've used which worked on the last Apache 2.x server I was working on.
– Jonathan
Jun 28 '15 at 12:51
I have just paste the code that you have provided in my htaccess file. But I am still facing the problem 404 error when I not use .php but site with .php extension is working check url a.sprybirds.com/business-search.php?find=food-beverage
– Kunwar Asif Ali Khan
Jun 28 '15 at 13:21
|
show 2 more comments
I have a multi domain hosting plan. my primary website is hosted in web-root folder and a htaccess file is also placed in this we-root. And my site a.sprybirds.com is hosted in this web-root folder in sequence of folders web-root/sub_folder/site_folder . And I have another htaccess file in this site folder site_folder. I have provided the code in my is of htaccess file inside site_folder.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:28
@KunwarAsifAliKhan did you try removing the two lines as noted above? If so, did the error persist? Ideally, those two lines should be removed from all .htaccess files while troubleshooting. You can test whether or not you actually need -Indexes. Simply create an empty directory anywhere and access it. If you can browse it, then GoDaddy doesn't have this option enabled (although they really should...). If you can't browse, then this option isn't needed.
– Jonathan
Jun 28 '15 at 11:34
i have removed the above two line from htaccess file and my site is not showing internal sever error but another pages like a.sprybirds.com/business-search?find=food-beverage showing 404 error. I have used this htaccess to remove php extension and I have removed .php from all urls of my website.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:47
@KunwarAsifAliKhan Please see the modified post above. I've added an example I've used which worked on the last Apache 2.x server I was working on.
– Jonathan
Jun 28 '15 at 12:51
I have just paste the code that you have provided in my htaccess file. But I am still facing the problem 404 error when I not use .php but site with .php extension is working check url a.sprybirds.com/business-search.php?find=food-beverage
– Kunwar Asif Ali Khan
Jun 28 '15 at 13:21
I have a multi domain hosting plan. my primary website is hosted in web-root folder and a htaccess file is also placed in this we-root. And my site a.sprybirds.com is hosted in this web-root folder in sequence of folders web-root/sub_folder/site_folder . And I have another htaccess file in this site folder site_folder. I have provided the code in my is of htaccess file inside site_folder.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:28
I have a multi domain hosting plan. my primary website is hosted in web-root folder and a htaccess file is also placed in this we-root. And my site a.sprybirds.com is hosted in this web-root folder in sequence of folders web-root/sub_folder/site_folder . And I have another htaccess file in this site folder site_folder. I have provided the code in my is of htaccess file inside site_folder.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:28
@KunwarAsifAliKhan did you try removing the two lines as noted above? If so, did the error persist? Ideally, those two lines should be removed from all .htaccess files while troubleshooting. You can test whether or not you actually need -Indexes. Simply create an empty directory anywhere and access it. If you can browse it, then GoDaddy doesn't have this option enabled (although they really should...). If you can't browse, then this option isn't needed.
– Jonathan
Jun 28 '15 at 11:34
@KunwarAsifAliKhan did you try removing the two lines as noted above? If so, did the error persist? Ideally, those two lines should be removed from all .htaccess files while troubleshooting. You can test whether or not you actually need -Indexes. Simply create an empty directory anywhere and access it. If you can browse it, then GoDaddy doesn't have this option enabled (although they really should...). If you can't browse, then this option isn't needed.
– Jonathan
Jun 28 '15 at 11:34
i have removed the above two line from htaccess file and my site is not showing internal sever error but another pages like a.sprybirds.com/business-search?find=food-beverage showing 404 error. I have used this htaccess to remove php extension and I have removed .php from all urls of my website.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:47
i have removed the above two line from htaccess file and my site is not showing internal sever error but another pages like a.sprybirds.com/business-search?find=food-beverage showing 404 error. I have used this htaccess to remove php extension and I have removed .php from all urls of my website.
– Kunwar Asif Ali Khan
Jun 28 '15 at 11:47
@KunwarAsifAliKhan Please see the modified post above. I've added an example I've used which worked on the last Apache 2.x server I was working on.
– Jonathan
Jun 28 '15 at 12:51
@KunwarAsifAliKhan Please see the modified post above. I've added an example I've used which worked on the last Apache 2.x server I was working on.
– Jonathan
Jun 28 '15 at 12:51
I have just paste the code that you have provided in my htaccess file. But I am still facing the problem 404 error when I not use .php but site with .php extension is working check url a.sprybirds.com/business-search.php?find=food-beverage
– Kunwar Asif Ali Khan
Jun 28 '15 at 13:21
I have just paste the code that you have provided in my htaccess file. But I am still facing the problem 404 error when I not use .php but site with .php extension is working check url a.sprybirds.com/business-search.php?find=food-beverage
– Kunwar Asif Ali Khan
Jun 28 '15 at 13:21
|
show 2 more comments
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f702119%2fhow-to-remove-php-extension-using-htaccess-on-godaddy-linux-hosting%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does your error log say? If it's throwing a 500 Internal, there's some kind of cause and the logfile should give you more detail about why that is.
– ldennison
Jun 28 '15 at 7:28
Can
#
occur in a request at all?– Hagen von Eitzen
Jun 28 '15 at 13:48
if you are using godaddy, linux shared hosting, than try this article, it will get you the results.kvcodes.com/2016/02/godaddy-remove-php-extension
– Kvvaradha
Feb 17 '16 at 10:30