Restructure urls using .htaccess file - php

I need to convert links such as
http://www.example.co.uk/blog/archive.php?date=2012-05
to
http://www.example.co.uk/blog/archive/2012/05/
using php or .htaccess file.
.htaccess file
RewriteEngine on
RewriteRule ^blog/archive/([0-9]+)/([0-9]+)/$ http://www.example.co.uk/blog/archive.php?date=$1-$2 [NC]
Ive have tried this but not having any luck. Any ideas or help would be appreciated.

Put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^blog/archive/([0-9]+)/([0-9]+)/?$ blog/archive.php?date=$1-$2 [NC,L,QSA]

Related

How to modify this URL in .htaccess?

I want to modify URL with a check.
If there exists experiment as second folder, then do this
{site}.com/dashboard/experiment/closed/.../
to
{site}.com/experiment/closed/.../
If no experiment found in path, then don't do anything. For eg
{site}.com/dashboard/ex-view/closed/.../
How do I achive this using htaccess. I'm using Laravel 5.1.
This is what I tried but it doesn't meet the second condition.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^experiment/(.*)$ /$1 [L,NC,R]
You can try this rule in the .htaccess in the root. The should only affect URL with experiment as the second folder.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^.+/experiment/(.*)$ /experiment/$1 [L,NC,R]

Htaccess rewrite no extension or slash

I want every file on my server like this
"mywebsite.com/video?id=vgIjgt863_53",
I have php so at the moment it would look like this
"mywebsite.com/video.php?id=(id)"
I need this in htaccess
Put your htaccess in root folder with this code
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.+)$
RewriteRule ^video$ /video.php?id=%1 [L]

.htaccess redirecting the display images in other server

Can you help me out with my problem about .htaccess redirecting the display images in other server..
i got this in my .htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ http://www.newurl.com/folder/folder/i/m/img_4fa231e793149_s.png
[NC,L]
this htaccess only redirects only one images which is img_4fa231e793149_s.png
i would like to do is to retrieve all the images which is here ->http://www.newurl.com/folder/folder/i/m/...
any help is appreciated thanks a lot....
Use your captured group $1:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /magento/media/catalog/product/i/m/
RewriteRule ^(img_[^.]+\.(?:jpg|png|jpeg|gif))$ http://www.tokopals.com/Dan/Magento_images/i/m/$1 [NC,L,R]

How to redirect url to parent directory with url rewriting

I need to make redirections from a sub-directory to the parent directory.
In other words I have to redirect anything matching
http://exemple.com/portfolio/product1
to :
http://exemple.com/product1
Is there any way to do that with URL REWRITE ?
Thanks
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^portfolio/(.*)$ /$1 [L,R=301,NC]
You want to put this into .htaccess inside the directory that you want to be redirrected
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/parent
RewriteRule ^(.*)?$ http://%{HTTP_HOST}/parent

URL rewrite problems

I am working on www.quippoauctions.com site here I am facing one problem. I have a
url: http://www.quippoauctions.com/index.php?do=auctiondetails&id=1134
i want to show this url as
http://www.quippoauctions.com/auctiondetails/1134/demo_auction_for_training_purpose.html
with the help of .htaccess file acn anyone help me on this
I have an htaccess file where I am writing
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^auctiondetails/(.*)/(.*).html$ ?do=auctiondetails&id=$1
try this
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/(.*)/demo_auction_for_training_purpose\.html$ /index.php?do=$1&id=$2
OR
RewriteRule ^auctiondetails/1134/demo_auction_for_training_purpose.html$ index.php?do=auctiondetails&id=1134 [L]

Categories