I have this .htaccess which basically is supposed to turn my links from
http://www.dsbigiena.ro/products.php?product-id=Colac-wc-cu-folie-de-plastic-cu-actionare-manuala-prin-buton
to
http://www.dsbigiena.ro/Colac-wc-cu-folie-de-plastic-cu-actionare-manuala-prin-buton/
Unfortunately, it's not doing it.
Did I write it wrong?
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]*)/$ /products.php?product-id=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
EDIT: I did indeed test the .htaccess with "deny from all", and it works.
Your current rewrite rule only resolve a pretty URL. It won't convert an actual /products.php URL to the pretty one by itself. You need to have an explicit rule for that as
RewriteEngine On
RewriteBase /
# Redirects from a normal URL to a pretty one
RewriteCond %{THE_REQUEST} \ /products\.php\?product-id=([^\ ]+) [NC]
RewriteRule ^ /%1/? [L,R=301]
# Resolves the pretty URL
RewriteRule ^([^/]+)/?$ /products.php?product-id=$1 [QSA,L]
Related
i want to change url by htaccess from http://localhost/projectname/cab-details.php?v_name=variable to http://localhost/projectname/variable Here variable is a link(slug) Now My htaccess code is
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^$1/([a-zA-Z-0-9-]+) cab-details.php?v_name=$1
With your shown samples please try following .htaccess rules file. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteBase /omm/
##External redirect rules here.
RewriteCond %{THE_REQUEST} \s/(omm/[^.]*)\.php\?v_name=(\S+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
##Internal redirect rules here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^omm/([^/]*)/([^/]*)/?$ $1.php?v_name=$2 [QSA,NC,L]
Here is my url:
website.com/index.php?folder=cars&type=ford
and would like it to be website.com/cars/ford and all pages point to index.php that I will grab the params from the url.
I can't seem to get it, here is my .htaccess:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /index.php?folder=$1&app=$2 [L]
This is one example I got from a clean url generator but its not working. Any ideas?
You can insert this rule just below RewriteEngine On to redirect old URL to pretty URL:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php\?folder=([^\s&]+)&type=([^\s&]+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?folder=$1&app=$2 [L,QSA]
So the problem I'm looking at and haven't managed to solve!
For example the url is http://someurl.com/brands/brand
What I want to accomplish is that htaccess lets te request go to url: http://someurl.com/brands/brand but removes the "brands" part from the url.
Also if the url: http://someurl.com/brands is called the page "brands" needs to be displayed. So only when there is a brand after /brands/ it needs to do a URL rewrite to http://someurl.com/brand
I have tried this but this piece does a redirect to the new location witch doesn't exist.
RewriteRule ^onze-merken/(.*)$ /$1 [L,R=301]
So I need the above with out the redirect, it only needs to rewrite the URL.
Any help would be greatly appreciated, Thanks!
This is now my htaccess part where the rewriting is done!
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /onze-merken/(\S+)\s [NC]
RewriteRule ^ /%1 [R=302,L,NE]
# Only rewrite if the directory doesn't exist.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# internal forward from pretty URL to actual one
RewriteRule ^((?!onze-merken/).+)$ /onze-merken/$1 [L,NC]
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
RewriteRule ^(uploads/([a-z0-9_\-\.]+)/__images/custom/(.*)/)(.*)$ http://someurl.com/uploads/$2/__images/custom/$3/$4 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /brands/(\S+)\s [NC]
RewriteRule ^ /%1 [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!brands/).+)$ brands/$1 [L,NC]
good day
i am just stuck in the middle of something i want to remove .php extension and make one slash for example
my current url is
http://example.com/campus.php?college=BGIET,%20Sangrur
Now i want to change it to
http://example.com/campus/BGIET,Sangrur
Is it possible to do this i am clueless to how to make this happen
and yes /mod_rewrite is enabled
proof :-
RewriteEngine On
RewriteRule ^google.html$ http://www.google.com/ [R=301]
Going to http://www.example.com/google.html redirecting to Google.com so it is enabled..
help me out please ( ._.)
You can use this code in your DOCUMENT_ROOT/.htaccess file:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /campus\.php\?college=([^\s&]+)\%20([^\s&]+) [NC]
RewriteRule ^ campus/%1%2? [R=302,L,NE]
RewriteCond %{THE_REQUEST} /campus\.php\?college=([^\s&]+) [NC]
RewriteRule ^ campus/%1%2? [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^campus/(.+?)/?$ campus.php?college=$1 [NC,L,QSA]
Add this to your .htaccess in your web root / directory
RewriteEngine on
RewriteCond %{THE_REQUEST} \ /campus\.php\?college=([^\s&]+) [NC]
RewriteRule ^ /campus/%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^campus/(.*)$ /campus.php?college=$1 [NC,L]
The first rule makes sure that if the old URL is used, the user gets redirected to the new one automatically. The second rule resolves the non-php link to the php one behind the scenes.
URL : http://domainname.com/index.php?p=top-games
I need to rewrite this as http://domainname.com/top-games
How I do this using htaccess file? Please can any one give me the htaccess code.
Thanks
Try this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?p=$1 [QSA,L]
</IfModule
Create .htaccess file in your root folder and paste code
You're probably looking for redirect in reverse direction.
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?p=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ /index.php?q=$1 [L,QSA]