I'm new on php programming and i'm customizing an CRM base on PHP. I want to change the .php extension in .aspx, whether the php script is in the root file or sub directory, the .aspx should show up.
Here is my URL
I want to change THIS:
http://localhost/edev/pages/UI.php?operation=req
Into:
http://localhost/edev/pages/UI.aspx?operation=req
the code that i have tried
.HTACCESS
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://localhost/test/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://localhost/test/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
Let me know if you have any question according to this question. Thank You :)
Try this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.aspx$ $1.php [L]
Related
I have a problem for my php website, i do some research and my url look like this www.example.com/about, that's a correct output but i want to add extra forward slash so the url look like this www.example.com/about/ same with the wordpress behavior.
my .htaccess file:
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
thanks.
my url is like below :
http://localhost/project/test/jobs/?page=accounting
Accounting
And i want to make like below :
http://localhost/project/test/jobs/accounting
i have search other question but unable to make it. As i am totally unaware about this .htaccess rewrite process :(
however i have below code already in my htaccess file to remove .php extension :
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
please help me to append URL rewrite rule in above htaccess file without loosing .php ext rule.
you are making get request with params which remains as it is if u wana make post request then it will be somethong like this
http://localhost/project/test/jobs/accounting
What I normally do with link building is sending all my traffic to my index.php whitch splits it into a MVC framework, this is the important part of my .htaccess for you:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?path=$1 [L,QSA]
What does this .htaccess do rule by rule?
Options +FollowSymLinks
http://www.maxi-pedia.com/FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Checks or the requested file isn't a direct path to a directory or actual file, correct me if I am wrong, because I am not 100% sure.
RewriteRule (.*) index.php?path=$1 [L,QSA]
Rewrites the path from "/test/testings/lalalala" into "index.php?path=/test/testings/lalalala".
I hope that this was the answer where you were looking for.
I want to access some php files which are located inside some subfolders. I'm using a .htaccess file, which removes all the .php extensions.
Here is the file:
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.net/folder/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.net/folder/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
I have to say that I just copied this .htaccess file from a tutorial, because I have no experience in this area.
So a quick example: I can access www.example.net/folder/myphpfile.php , but I get a "file not found" error when I try to access www.example.net/folder/anotherfolder/myphpfile.php .
But it works when I delete the .htaccess file.
Can someone help me with this. Thanks!
Have it this way:
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} \s/.+?\.php
RewriteRule ^(.+)\.php$ /$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]
I am using one htaccess code (Core PHP) to hide php extension from url and its working great but not true with second segment of url
for example if url is http://www.abc.com/somepage than my code is running great but if url is
http://www.abc.com/xyz/sompage than my code will fail.
here is my code of htaccess
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://www.abc.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://www.abc.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $2.php [L]
Please help me to find out hte solution that no matter how much segments are there but it should take last segment as a php file
Thanks in advance
Try to add:
RewriteCond %{HTTP_HOST} !^www.abc.com/xyz [nc]
RewriteRule !^(.*)$ !http://www.abc.com%{REQUEST_URI} [R=301,L]
I just need to know how can I stop displaying my php pages name in url
for example:
http://cbse.in/classxii/question_papers.php to http://cbse.in/classxii/ or http://cbse.in/classxii/question_papers/
http://cbse.in/classxii/computer_science/question_papers.php to http://cbse.in/classxii/computer_science/ or http://cbse.in/classxii/computer_science/question_papers/
http://cbse.in/classxii/computer_science/Chapter1/answers.php to http://cbse.in/classxii/computer_science/Chapter1/ or http://cbse.in/classxii/computer_science/Chapter1/answers/
I came to know this is possible by URL rewriting in htaccess.
But not clear idea on this, it will great if someone show me the correct and clear way to do this.
Please refer this link for info about htaccess redirection. Also, pls make sure that you've got it enabled within Apache, the webserver.
http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
try this:
RewriteEngine on
#unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]
#redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.*)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.*)\.php$ $1 [R=301,L]
#resolve .php file for extensionless php urls
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
You need to use Mod Rewrite. You can use this one Mod Rewrite generator: http://www.generateit.net/mod-rewrite/