I have a link
http://www.mydomain.com/place/index.php?slug=antalya-hotels
and i want to write this like
http://www.mydomain.com/place/antalya-hotels.html
I have tried this
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /place/index.php?slug=$1 [L]
Bu didnt work. how we can do.
You can use:
RewriteEngine On
RewriteRule ^place/([^.]+)\.html$ /place/index.php?slug=$1 [L,QSA,NC]
OR
RewriteRule ^([^/]+)/([^.]+)\.html$ /$1/index.php?slug=$2 [L,QSA,NC]
Related
i'm trying to create multiple rewrite rules to make friendly URL but what i did, makes my website throw error 500.
I've tried this but can't seem to make it work.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*) /index.php?category=$1 [L]
RewriteRule ^(.*)/(.*) /index.php?category=$1&subcategory=$2 [L]
RewriteRule ^(.*)/(.*)/(.*) /index.php?category=$1&subcategory=$2&userid=$3 [L]
What i need is basically to make this urls work:
domain.com/GetAnnouncements as domain.com/index.php?category=GetAnnouncements
domain.com/Persona/GetAchievements/2 as domain.com/index.php?category=Persona&subcategory=GetAchievements&userid=2
and there also should be third option that works 'in between' without 3rd parameter which is &userid=2
With your shown samples please try following .htaccess rules file.
Make sure to use either 1st OR 2nd solution only at a time.
Please make sure:
To keep your .htaccess rules file, index.php file in your root location.
Clear your browser cache before testing your URLs.
1st solution: Generic rules where using regex.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([^/]*)/?$ /index.php?category=$1 [L]
RewriteRule ^([^/]*)/([^/]*)/?$ /index.php?category=$1&subcategory=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/(/d+)/?$ /index.php?category=$1&subcategory=$2&userid=$3 [L]
OR 2nd solution: Using specific string/URLs only as per your shown samples.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(GetAnnouncements)/?$ /index.php?category=$1 [NC,L]
RewriteRule ^(Persona)/(GetAchievements/)/?$ /index.php?category=$1&subcategory=$2 [NC,L]
RewriteRule ^(Persona)/(GetAchievements/)(/d+)/?$ /index.php?category=$1&subcategory=$2&userid=$3 [NC,L]
After some more googling and consulting with my friend we came to this solution which works:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)/(.*)/(.*)$ index.php?category=$1&subcategory=$2&userid=$3 [L,QSA]
RewriteRule ^(.*)/(.*)$ index.php?category=$1&subcategory=$2 [L,QSA]
RewriteRule ^(.*)$ index.php?category=$1 [L,QSA]
Thank you everyone who tried to help!
My .htaccess has the following code :
RewriteRule ^([A-Z]+)$ listings/$1 [R=301]
RewriteRule ^listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
With this rule I am trying to achieve 301 redirect from spb.com/test_1/XY to spb.com/test_1/listings/XY
However, it is redirecting to spb.com/path/to/test_1/in_server/test_1/listings/CT
and I tried changing .htaccess to as follows:
RewriteRule ^([A-Z]+)$ /listings/$1 [R=301]
RewriteRule ^listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
RewriteRule ^/([A-Z]+)$ /listings/$1 [R=301]
RewriteRule ^listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
RewriteRule ^/([A-Z]+)$ /listings/$1 [R=301]
RewriteRule ^/listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
Nothing seems to work.
Please guide me in this regard. Thank you community :)
Could you please try following, based on your shown samples only. Please make sure you clear your browser cache before testing your URLs
RewriteEngine ON
RewriteRule ^([A-Z]+)/?$ /test_1/listings/$1 [R=301]
RewriteRule ^test_1/listings/([A-Z]+)/?$ listings_state.php?state=$1 [NC,L]
I have an URL like these:
http://domain.com/database/movie/jurassic-park.1224.html
http://domain.com/artist/bruno-mars.104.html
I tried to resolve these URLs with the following RewriteRules, but they don't work.
RewriteEngine On
RewriteRule ^(.*)\/movie\/(.*)\.(.*)\.html$ ./index.php?area=movies&id=$2 [QSA]
RewriteRule ^(.*)\/artist\/(.*)\.(.*)\.html$ ./index.php?area=people&id=$2 [QSA]
Who can help me what's wrong?
Try these rules:
RewriteEngine On
RewriteRule movie/(.+?)\.(\d+)\.html$ index.php?area=movies&id=$2 [L,QSA,NC]
RewriteRule artist/(.+?)\.(\d+)\.html$ index.php?area=people&id=$2 [L,QSA,NC]
I need your precious help.
I have an url:
http://domain.com/v/12345
My ht access is set to pass 12345 to php script like:
htaccess:
RewriteRule ^v/([a-zA-Z0-9_-]+)$ /script.php?v=$1 [L]
script php:
http://domain.com/script.php?code=12345
and works perfectly but.. and there is a but, I would write my url so:
http://domain.com/12345/my-dog-is-very-fat
can you help to change my htaccess to works so? Because if I use /my-dog-is-fat or just / I get an 404 error.
I try to explain better:
I would share link with seo keywords in the url, example
mydomain.com/alphanumericCode/thi-is-my-dog-article
where alphanumericCode is get of myscript.php?V=
This is my htaccess:
RewriteEngine On
RewriteRule ^view/([a-zA-Z0-9_-]+)$ /view.php?v=$1
RewriteRule ^folder/([a-zA-Z0-9_-]+)$ /filefolderlist.php?f=$1
RewriteRule ^home$ /index.php [L]
RewriteRule ^report$ /report.php [L]
RewriteRule ^play/([a-zA-Z0-9_-]+)$ /play.php?v=$1 [L]
###Added by anubhava
RewriteRule ^v/([\w-]+)/?$ /script.php?v=$1 [L,QSA]
RewriteRule ^([0-9a-z]+)/.+$ /script.php?v=$1 [L,QSA,NC]
##end
RewriteRule ^privacy-policy$ /privacy.php [L]
ErrorDocument 404 404.php
You can have a new rule for the new URI scheme:
RewriteEngine On
RewriteRule ^v/([\w-]+)/?$ /script.php?v=$1 [L,QSA]
RewriteRule ^([0-9a-z]+)/.+$ /script.php?v=$1 [L,QSA,NC]
I am trying to rewrite from
mysite.com/pokerbono/xyz
to
mysite.com/pokerbono.php?id=XYZ
Here is the code I added in the .htaccess:
#### Affiliate Links
RewriteRule ^pokerbono/([a-zA-Z0-9_-]+)$ pokerbono.php?id=$1 [L]
What is wrong with this rule? I tried like 100 variations and always receive a 404.
I tried each and every variation right now I have in my .htaccess the following rows:
RewriteRule ^pokerbono/([a-zA-Z0-9_-]+)$ pokerbono.php?id=$1 [L]
RewriteRule ^pokerbono/([a-zA-Z0-9_-]+)/$ pokerbono.php?id=$1 [L]
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)$ pokerbono.php?id=$1 [L]
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)/$ pokerbono.php?id=$1 [L]
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)$ /pokerbono.php?id=$1 [L]
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)/$ /pokerbono.php?id=$1 [L]
Try including slashes on the front:
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)$ /pokerbono.php?id=$1 [L]
UPD:
This works in my environment:
RewriteEngine On
RewriteRule ^qwe/([-_a-zA-Z0-9]*)$ qwe.php?id=$1 [L]
I had to disable Multiviews, now it is working fine :)