htaccess - How to enable uppercase letters in URL? - php

I have the following htaccess code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.120
RewriteRule ^phpinformation.php /info.php [R,NC,L]
RewriteRule ^phpinformation /info.php [R,NC,L]
RewriteBase /
## hide .php extension # To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
This hides .php extension, as well as redirecting from http://192.168.1.120/phpinformation (URL that doesn't exist) to existing http://192.168.1.120/info URL.
I want to be able to call these URLs with uppercases as well as with lowercases: PHPINFORMATION,INFO,PHPINFORMATION.PHP,INFO.PHP.
How to modify this code to enable uppercase URL calls?

Related

PHP url rewrite doesnt happen even if I have configured in htaccess file

I have added .htaccess file inside my PHP project folder with the below content,
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
But when I try to access /project/enviroment if gives me a 404 page. and it doesnt refer the environment.php file internally. Is there any other configurations that I need to do? Thank you.

htaccess - Redirect dumb url to working url

I have the following .htaccess file that hides .php extension. That is, instead of showing http://address/info.php, it shows http://address/info.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
In htaccess file I need to add that phpinformation (which is dumb link - doesn't go anywhere: http://address/phpinformation) redirects to info. That is, http://address/phpinformation needs to be redirected to http://address/info
How should I modify the code?
Can you try this
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.120
RewriteRule ^phpinformation\.php /info.php [R,NC,L]
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

cannot hide php extension in .htaccess file on godaddy

Hello this is my code of .htaccess file . i have tried so many codes to hide the code but none id working please help me .. this is my full htaccess file.this hide code i found little bit good but this is showing my page content.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
ErrorDocument 404 http://www.mydomainname.com/
Options +FollowSymLinks
#Disable directory browsing
Options -Indexes
RewriteEngine on
#Redirect non-www to www
RewriteCond %{HTTP_HOST} ^mydomainname\.com$
RewriteRule (.*) http://www.mydomainname.com/$1 [R=301,L]
RewriteRule pages/(.*) page.php?page=$1
RewriteRule blog/(.*) blog.php?type=$1
RewriteRule post/(.*)/(.*) post.php?pid=$1&name=$2
RewriteRule news-and-events/(.*)/(.*) news.php?nid=$1&name=$2
i found many code but none is working
Use this .htaccess
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

mod_rewrite and .htaccess exception to the rule

I want to hide the .php extension throughout my site, I have this snippet and it works fine. However I have one URL that I want to be an exception to the rule, that is I want it have the .php intact and all it's $_GET params.
How can I include that exception into this snippet? And why does it work?
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=302,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
You can add exception like this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule !^(exception1|exception2) %1/ [R=302,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
btw this code and comment look like something I would have written it in the past :)

php htaccess multiple extensions

Ok for example i want: youtube.com/channel.php?c=pinch
to be : youtube.com/channel/pinch
i have tried the code,but i dont know how to add an extension to an extension.. (channel/pinch), it stays as ex. youtube.com/channel?c=Pinch...
#Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
Could somebody fix the code and add to the code so i have the extension? Thanks!

Categories