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]
Related
I know this might be a simple fix but I cannot figure it out.
I have my .htaccess file in folder called videos that is in my root file.
I wrote this rewrite mod:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^videos/([a-z0-9\-]+)$ vid.php?=$1 [L]
</IfModule>
For some reason my url still comes up like this:
http://localhost/fap2/videos/vid.php?id=1
It does not replace that ?id=1 with just the number 1 like vid.php/1
Also since that vid.php?id=1 is from a href on index.php, and It looks like this:
<a href="videos/vid.php?id=' . $tag["video_tag"] .'">
my pages are based on that id. Can I somehow show the id category name instead of a numer so for example that vid.php?id=1 be that actual name vid.php/category1 or is that based on changing that a href tag?
Thank you
try this
RewriteEngine on
RewriteBase /fap2/
RewriteRule ^videos/([^/]+) vid.php?id=$1 [L]
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]
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]
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]