I've the links as follow:
localhost/a/site/watch/contact/
localhost/a/site/details/about/
where .htaccess file is in site folder
All I want to do is remove watch and details from the url like:
localhost/a/site/contact/
localhost/a/site/about/
Update
#Options -Indexes
#Options +FollowSymLinks
RewriteEngine On
#Exclude myadmin directory from the second level links
RewriteRule ^(myadmin)(/.*)?$ - [L]
RewriteRule ^(source)(/.*)?$ - [L]
ErrorDocument 404 /404.html
RewriteRule ^([a-zA-Z0-9_\-]+)/?$ index.php?task=$1 [L]
#Redirect 2nd level links to index.php
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)?$ index.php?task=$1&slug=$2 [L]
#Redirect 3rd level links to index.php
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)?$ index.php?task=$1&slug=$2&page=$3 [L]
#Redirect 4th level links to index.php
RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)?$ index.php?task=$1&slug=$2&title=$3&page=$4 [L]
I've tried following but this doesnot work
#RewriteRule ^/(.*)$ /watch/$1
RewriteBase /a/site
RewriteCond %{HTTP_HOST} ^/watch/
RewriteRule /(.*) /watch/$1 [QSA,L]
RewriteRule /(.*) /details/$1 [QSA,L]
RewriteRule /(.+) /watch/$1/index.php [NC,L]
RewriteCond %{THE_REQUEST} \ /+watch/
RewriteRule ^watch/(.*)$ /$1 [L,R=301]
Insert these 2 rules just below RewriteEngine On line in /a/site/.htaccess:
RewriteRule ^(contact)/?$ index.php?task=watch&slug=$1 [L,QSA,NC]
RewriteRule ^(about)/?$ index.php?task=details&slug=$1 [L,QSA,NC]
Related
I want Redirecting Subfolder to Subdomain with htaccess
I have this code
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sitename.com[NC]
RewriteRule ^(.*)$ http://www.sitename.com$1 [L,R=301]
RedirectMatch 301 ^/subfolder/(.*)$ http://subdomain.sitename.com/$1
but when redirect categories get link like this
http://subdomain.sitename.com/5/cat?c=5
it should become like this
http://subdomain.sitename.com/5/cat
this is the full htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^game-([0-9]+).html$ file.php?f=$1 [L]
RewriteRule ^([0-9]+)/(.+?)/([a-zA-Z]+)?/?([0-9]+)\.html$ browse.php?c=$1&p=$4 [L]
RewriteRule ^([0-9]+)/(.+?)?$ browse.php?c=$1 [L]
RewriteRule ^profile/([0-9]+)/.+\.html$ profile.php?u=$1 [L]
RewriteRule ^page/(.+)\.html$ page.php?p=$1 [L]
RewriteRule ^scores/([0-9]+)/([0-9]+)\.html$ scores.php?f=$1&p=$2 [L]
RewriteRule ^game-[0-9]$ $1.php [L]
RewriteRule ^game-[0-9]$ arcade/gamedata/$1 [L]
RewriteRule ^g([0-9]+)/?$ links.php?a=short&f=$1 [L]
RewriteRule ^tag/(.+?)(|/|/([0-9]+)\.html)$ search.php?t=$1&p=$3 [L]
</IfModule>
thanks
This is my .htaccess file i just want to rewrite the page from one url to another.But it moved 404 page
RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteRule ^([^/]+)/article/([^/]+)$ /index.php?option=com_vendorsearch&view=article&title=$2 [L]
RewriteRule ^([^/]+)/polls/([^/]+)$ /index.php?option=com_vendorsearch&view=polls&id=$2 [L]
RewriteRule ^([^/]+)/coupons/([^/]+)$ /index.php?option=com_vendorsearch&view=coupons&id=$2 [L]
RewriteRule ^([^/]+)/images/([^/]+)$ /index.php?option=com_vendorsearch&view=images&id=$2 [L]
RewriteRule ^([^/]+)/videos/([^/]+)$ /index.php?option=com_vendorsearch&view=videos&id=$2 [L]
Probably you need your first rules as:
RewriteRule ^[^/]+/articles/([^/]+)/?$ /index.php?option=com_vendorsearch&view=article&title=$1 [L,QSA,NC]
I'm trying to redirect multiple situation to my oscommerce store located in a folder
mydomain.com/osc without www
Please help me in redirecting...
My OSC is installed in a folder /store/
I want all domain.com or www.domain.com to redirect to domain.com/store
also permanent redirect old domain folder /shop/ with or www to /store/
I've tried it but a strange issue appears, it work fine for products but when I access info pages with www.domain.com/store/contact_us.php it redirect to domain.com/contact_us.php and give 404 error (ofcourse there is nothig)
here is .htaccess of my root (domain.com)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ http://ambiancehome.ca/store/ [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^$ http://domain.com/store [R=301,L]
#additional redirect of a product which is moved/removed / changed
Redirect 301 /store/bed-loungers-c-21.html http://ambiancehome.ca/store/product_info.php/bed-lounge-back-rest-reading-pillow-p-104.html
Here is .htaccess of /store/ folder
Options +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase instructions
# Change RewriteBase dependent on how your shop is accessed as below.
# http://www.mysite.com = RewriteBase /
# http://ambiancehome.ca/store/ = RewriteBase /store/
# http://www.mysite.com/catalog/shop/ = RewriteBase /catalog/shop/
# Change RewriteBase using the instructions above
RewriteBase /store/
RewriteRule ^([a-z0-9/-]+)-p-([0-9]+).html$ product_info.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-c-([0-9_]+).html$ index.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-m-([0-9]+).html$ index.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-pi-([0-9]+).html$ popup_image.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-pr-([0-9]+).html$ product_reviews.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-pri-([0-9]+).html$ product_reviews_info.php [NC,L,QSA]
# Articles contribution
RewriteRule ^([a-z0-9/-]+)-t-([0-9_]+).html$ articles.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-au-([0-9]+).html$ articles.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-a-([0-9]+).html$ article_info.php [NC,L,QSA]
# Information pages
RewriteRule ^([a-z0-9/-]+)-i-([0-9]+).html$ information.php [NC,L,QSA]
# Links contribution
RewriteRule ^([a-z0-9/-]+)-links-([0-9_]+).html$ links.php [NC,L,QSA]
# Newsdesk contribution
RewriteRule ^([a-z0-9/-]+)-n-([0-9]+).html$ newsdesk_info.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-nc-([0-9]+).html$ newsdesk_index.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-nri-([0-9]+).html$ newsdesk_reviews_info.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-nra-([0-9]+).html$ newsdesk_reviews_article.php [NC,L,QSA]
</IfModule>
Keep your root .htaccess just like this only:
RewriteEngine on
RewriteRule ^$ /store/ [R=301,L]
I have a lithium installation and all the .htaccess works fine.
I need to install OpenCart as a shopping cart in app/webroot/shop
I copied all the files and also changed the .htaccess file in the root folder of lithium installation as
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule shop/(.*) /app/webroot/shop/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Still when I browse http://domain.com/shop it takes me to http://domain.com/app/webroot/shop/
With an error on page:
Exception
lithium\action\DispatchException (code 404)
Action `webroot` not found.
Please help me in solving this problem.
You may try this instead:
<IfModule mod_rewrite.c>
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/app/webroot/shop/? [NC]
RewriteRule ^shop/(.*) /app/webroot/shop/$1 [L,NC]
RewriteCond %{REQUEST_URI} !/app/webroot/? [NC]
RewriteRule ^$ /app/webroot/ [L,NC]
RewriteCond %{REQUEST_URI} !/app/webroot/? [NC]
RewriteRule ^(.*) /app/webroot/$1 [L,NC]
</IfModule>
The problem is that your last "catch all" rule is also redirecting all requests for the shop to lithium, which you don't want.
Try this
Options +FollowSymlinks -MultiViews
RewriteEngine On
# Rewrite all URLs that start with /shop to /app/webroot/shop
RewriteRule ^shop/.? /app/webroot/shop%{REQUEST_URI} [L]
# Rewrite all URLs that don't start with /app/webroot/shop to /app/webroot
RewriteCond %{REQUEST_URI} !^/app/webroot/shop
RewriteRule .? /app/webroot%{REQUEST_URI} [L]
Can sombody help me out with this, im trying to re direct a page using htaccess file but it keeps adding ?c=oldpage on to the end of the new url, example:
http://www.mydomain.co.uk/newpage.html?c=oldpage
i have tried some of the solutions posted here but no luck, here is my .htaccess file:
DirectoryIndex index.php index.html index.htm
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} PHPSESSID=.*$
RewriteRule (.*) http://www.mydomain.co.uk/$1? [R=301,L]
RewriteCond %{HTTP_HOST} ^mydomain.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L]
RewriteEngine on
RewriteRule ^product/(.*).html$ product.php?p=$1 [L]
RewriteRule ^(.*)\.html$ category.php?c=$1 [L,NC]
Redirect 301 /oldpage.html http://www.mydomain.co.uk/newpage.html
ErrorDocument 404 /404.php
Thanks for any help.
This is mod_alias (the Redirect directive) and mod_rewrite not playing nicely with each other. Because both modules apply their directives on the same URI in the URL-file mapping pipeline, they don't know to ignore each other since neither directive knows what the other module is doing. Since you're targets overlap, both modules are applying their directives on the same URI and you get a mish-mashed result.
You need to stick with mod_rewrite in this case and move the redirect above the internal rewrites:
DirectoryIndex index.php index.html index.htm
Options +FollowSymLinks
RewriteEngine on
# redirects
RewriteCond %{QUERY_STRING} PHPSESSID=.*$
RewriteRule (.*) http://www.mydomain.co.uk/$1? [R=301,L]
RewriteCond %{HTTP_HOST} ^mydomain.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} /index\.php\ HTTP/
RewriteRule ^index\.php$ / [R=301,L]
RewriteRule ^oldpage.html$ http://www.mydomain.co.uk/newpage.html [R=301,L]
# internal rewrites
RewriteRule ^product/(.*).html$ product.php?p=$1 [L]
RewriteRule ^(.*)\.html$ category.php?c=$1 [L,NC]
ErrorDocument 404 /404.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abc\.net$
RewriteRule ^example\.html$ "http\:\/\/abc\.net\/example\/" [R=301,L]
RewriteOptions inherit
to a folder, or:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abc\.net$
RewriteRule ^example\.html$ "http\:\/\/abc\.net\/example\.html$" [R=301,L]
RewriteOptions inherit
Don't know much about it, but it's what i use, hope it helps.