Can you help create a mod re write rule for this url please
http://localhost/view.php?item_id=28&sef=2009-bristol-blenheim-in-west-yorkshire
i want it to go to
http://localhost/view.php?item_id=28
and i want my link to look like this
http://localhost/view/28/2009-bristol-blenheim-in-west-yorkshire
i am currently using this rule for another page
RewriteRule ^category/[!/.]*([A-Za-z]+)/?$ /browse.php?cat=$1 [NC,L]
but cant seem to update it to work for this one..
current htaccess
RewriteEngine On
Options +FollowSymLinks
# Browse Category
RewriteRule ^category/[!/.]*([A-Za-z]+)/?$ /browse.php?cat=$1 [NC,L]
# View Item
RewriteRule ^view/([0-9]+)/([a-zA-Z0-9-]+)$ /view.php?item_id=$1&sef=$2 [NC]
the browse category is working, View item is not
If you want a request such as
http://localhost/view/28/2009-bristol-blenheim-in-west-yorkshire
to silently become a server request for
http://localhost/view.php?item_id=28&sef=2009-bristol-blenheim-in-west-yorkshire
Then try this:
RewriteRule ^view/([0-9]+)/([a-zA-Z0-9-]+)$ /view.php?item_id=$1&sef=$2 [NC]
Related
I want to setup a redirect on my site to go to a different domain which I am able to do so with this rewrite rule:
RewriteEngine on
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]
This works great but there are also a few pages that I want to completely change the url as well as redirect to the new domain. Here is an example:
1.) Here is an example url to my old domain. https://www.olddomain.com/product-tag/[tag-name]/. I want this go to https://www.newdomain.com/parts?category=[tag-name]/.
2.) Here is an example url to my old domain. https://www.olddomain.com/product-categories/[category-name]/garbage. I want this go to https://www.newdomain.com/parts?category=[category-name]/.
I was hoping that adding something like this would do the trick but it does not seem to be working:
RewriteEngine on
RewriteRule ^/product-tag/(.*)$ https://www.newdomain.com/parts?category=$1 [R=301,L]
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]
How can I achieve this?
Have it like this:
RewriteEngine on
# handle both specific URL redirects
RewriteRule ^/?product-(?:tag|categories)/([\w-]+) https://www.newdomain.com/parts?category=$1 [R=301,L,NC,QSA]
# redirect everything else
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L,NE]
i have a url
http://domain.com/wallpaper-name-of-wallpaper-id.html
where wallpaper- is prefix of the url and name-of-wallpaper is title of the wallpaper while id is the actual id of the wallpaper. my current .hataccess file looks like.
RewriteRule ^wallpaper-([^/]*)\.html$ wallpaper.php?permalink=$1 [L]
but i want to change it to
http://domain.com/wallpaper/name-of-wallpaper-id.html
so user who will enter the old url will automatically sent to the new url with htaccess.
i have tried.
RewriteRule ^wallpaper-([^/]*)\.html$ wallpaper/wallpaper.php?permalink=$1 [R,L]
but don't seems to work for me. any idea or help?
Add a new redirect rule before existing rule:
Options -MultiViews
RewriteEngine On
RewriteRule ^(wallpaper)-([^.]+\.html)$ /$1/$2 [R=302,L,NC]
RewriteRule ^wallpaper/([^.]+)\.html$ wallpaper.php?permalink=$1 [L,NC,QSA]
I have a question regarding the .htaccess file.
I have rewritten a dynamic url in a static one as following:
www.mysite.com/index.php?lang=IT
in
www.mysite.com/it
using this rewrite rule:
RewriteEngine On
RewriteRule ^it/([^/]*)\.html$ /index.php?lang=$1 [L]
So far so good...
Now I need to create another static url for a dynamic url which redirects to the product description
www.mysite.com/product_details.php?id=1485
The rule inserted in the .htaccess is:
RewriteEngine On
RewriteRule ^it/prodotto-([^-]*)-([^-]*)\.html$ /it/product_details.php?id=$1&lang=$2 [L]
Unfortunately if I click on the related link I cannot reach the requested page; but if I comment the first rule like this
#RewriteRule ^it/([^/]*)\.html$ /index.php?lang=$1 [L]
then I can see the page.
Do you know how to solve this issue?
Assuming that lang equals to language you want the script do like so?
RewriteEngine On
RewriteBase /
RewriteRule ^it/([^/]*).html$ /index.php?lang=$1 [L]
RewriteRule ^it/prodotto-([^/]*)-([^/]*).html$ /it/product_details.php?id=$1&lang=$2 [L]
this will do
yoursite.com/it/$1.html
and
yoursite.com/it/prodotto-$1-$2.html
?
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 some help with mod_rewrite rule in apache.
This module is installed and working, i have tested it with wordpress permanent links and it works fine.
Now i have another website where want to apply the url change.
my main domain : www.mydomain.com
the current adress for my posts. www.mydomain.com/post.php?id=111
i need to change this adress to:
www.mydoman.com/year/month/post title here
EDIT!
For example this works great for me
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^id=([^/.&]+)/?$
RewriteRule ^post\.php$ /%1? [NS,R=301,L]
RewriteRule ^([^/.]+)/?$ post.php?id=$1&redirect=no [NS,QSA]
but it only show www.mydomain.com/postID
Please any kind of help ?
You'll have to add the ID to your URL, there's just no other simple way to do it:
URL = www.mydoman.com/year/month/post-title/111
RewriteEngine On
RewriteRule ^.*/.*/.*/([0-9]*)$ post.php?id=$1 [L]