php htaccess multiple extensions - php

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!

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 - How to enable uppercase letters in URL?

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?

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]

removing .html or .PHP URL extension using .htaccess not working

can anyone help me to remove .html or .php extension in URL.
I am trying this below code in my php project, but it is not working.
I have tried so many .htaccess codes, but nothing helps me..
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.php
Thanks in advance
Previously I also faced problem with removing .html or .php extension form URL.
I have a Solution Here
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]
put the above code in .htaccess file, above code is for .php files.
for .html files go through the below code
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.html to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [L]
I just replaced the .php with .html
Hope it helps You.. :)

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]

Categories