I'm trying URL re-writing for the first time and I have the following URLS which need rewriting:
http://domain.com/resorts.php?countryname=Portugal
http://domain.com/rss.php?destination=Torremolinos&itemtype=rfamily
I've written the following in my .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /countryname/(.*)/ resorts.php?countryname=$1
RewriteRule /destination/(.*)/itemtype/(.*)/ rss.php?destination=$1&itemtype=$2
But when I try the following, I keep getting URL not found. Please can someone point out what I may be doing wrong? Many thanks in advance.
http://domain.com/countryname/Portugal
http://domain.com/destination/Torremolinos/itemtype/rfamily
You can use this:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule countryname/(.*)/? resorts.php?countryname=$1 [NC,L]
RewriteRule destination/(.*)/itemtype/(.*)/? rss.php?destination=$1&itemtype=$2 [NC,L]
Related
I want rewrite below url
http://www.example.com/page.php?n=About%2BUs&id=F534Z531G538
to
http://www.example.com/about-us
using .htaccess file.
i have tried below code in my .htaccess
Options +FollowSymlinks
RewriteEngine on
rewriterule ^page.php?n=About%2BUs&id=F534Z531G538(.*)$ http://www.example.com/about-us$1 [r=301,nc]
but this is not working and also id is randomly generate.
anyone can help me ?
try this
RewriteRule ^about-us/([a-zA-Z0-9]+)$ page.php?id=$1
for http://www.example.com/about-us/f14dfa
for http://www.example.com/about-us
RewriteRule ^about-us$ page.php
I have dynamic url like
http://epathasala.com/schooldetails.php?name=john-paul-higher-secondary-school
http://epathasala.com/universitydetails.php?name=demo-university
http://epathasala.com/schooldetails.php?name=tagore-international-school
I need to remove all the query string and change the url like below
http://epathasala.com/collegedetails/gtn-arts-college
http://epathasala.com/universitydetails/demo-university
http://epathasala.com/schooldetails/tagore-international-school
I have tried [Pretty URL - mod_rewrite question][1] But not working. Please some one help. Thanks
I have tried this below htaccess code but its not working.
RewriteEngine On
RewriteBase /
RewriteRule ^epathasala/schooldetails/(.*)$ /epathasala/schooldetails.php?name=$1 [NC,L]
I need to remove this part ".php?name=" from the url.
RewriteRule ^(.*?)/(.*?)/?$ $1.php?name=$2 [NC,L]
This should work :
RewriteEngine On
RewriteBase /
RewriteRule ^epathasala/([^/]+)/([^/]+)/?$ /epathasala/$1.php?name=$2 [NC,L]
I have this url:
details
the url becomes in addressbar:
http://web228.sydney.webhoster.ag/soputnik/drive_to_london/?procid=12
but I want to process the logic in details.php.
How can I process the data in details.php in background and keep the first url in the address?
I tried this:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^drive_to_(.*)$ http://web228.sydney.webhoster.ag/soputnik/details.php [R=301,L]
but it is not working, error is: NOT FOUND
please help
Substitute your code with this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^test/drive_to_(.*?)/?$ /test/details.php [L,NC]
If you don't want the URL to change, then it's not a redirect, just a rewrite.
Change:
RewriteRule ^/test/drive_to_(.*)$ /test/details.php [R=301,L]
To something like:
RewriteRule ^/test/drive_to_(.*)$ /test/details.php?city=$1 [L]
dont forget to pass any url params to details.php.
Rewriterule ^/drive_for_(.*)/\?(.*)$ http://domain.de/test/details.php/?$1 [R=301,L]
it seems relevant that you want to pass the city name as well, otherwise that context gets lost in the rewrite. If that is another url param you could pass it through to details.php as such
Rewriterule ^/drive_for_(.*)/\?(.*)$ http://domain.de/test/details.php/?$2&city=$1 [R=301,L]
I need to change
http://localhost/engineering/management/administrator/modules/course/view.php
to
http://localhost/engineering/course_view.php
using htaccess
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)_(.*)\.php$ management/administrator/modules/$1/$2.php
RewriteRule ^(.*)_(.*)\.php$ management/user/modules/$1/$2.php
Works fine for this,
But for the below url its not working
http://localhost/engineering/management/user/modules/data/edit.php
Please try with this code:-
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)_(.*)\.php$ management/administrator/modules/$1/$2.php
RewriteRule ^(.*)_(.*)\.php$ management/user/modules/$1/$2.php
Hope it helps.
when you use this one!
RewriteRule (.*)_(.*)\.php management/administrator/modules/$1/$2.php
because it's possile ro rewrite other URLs(that you've mentioned), you can add special part to it to avoid such thing. e.g:
RewriteRule swd(.*)_(.*)\.php management/administrator/modules/$1/$2.php
and url:
http://localhost/engineering/swdcourse_view.php
and for second one, use other characters than swd!!
RewriteRule ^usr(.*)_(.*)\.php$ management/user/modules/$1/$2.php
I'm using the following htaccess:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^CuraXL/(.*)$ "CuraXL/index.php?pageRequest=$1"
RewriteRule ^CuraXL/(.*)/$ "CuraXL/index.php?pageRequest=$1"
When Doing the following in php:
<?php echo $_GET['pageRequest']; ?>
It outputs "index.php". Instead of what i request being "about-us".
Any idea what's up?
No, CuraXL/index.php is also matched by ^CuraXL/(.*)$. You need to exclude the destination you are rewriting to:
RewriteCond $1 !=index.php
RewriteRule ^CuraXL/(.*)/?$ CuraXL/index.php?pageRequest=$1
Remove the quotes around the index.php bit in the .htaccess