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]
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
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]
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]
I want to hide all my page names and extension from url,
htt://www.domain.com/innerpage.php
to
http://www.domain.com/
and
http://www.domain.com/subfolder/innerpage.php
to
http://www.domain.com/subfolder/
and
http://www.domain.com/subfolder/subfolder/innerpage.php
to
http://www.domain.com/subfolder/subfolder/
I used like
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ http://www.domain.com/$1/ [R=301,L]
RewriteRule ^(.*)$ http://www.domain.com/subfolder/$1/ [R=301,L]
RewriteRule ^(.*)$ http://www.domain.com/subfolder/subfolder/$1/ [R=301,L]
RewriteRule ^(.*)/$ $1.php [L]
its not work
I think this will work for you
DirectoryIndex innerpage.php index.php index.html index.htm
Put this as first line of your .htaccess. This directive will look for innerpage.php if no page has been specified for a directory. If you want to hide all pages in your site URL's then it's not a good idea IMO.
Give this set of directives a try:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/?$ /innerpage.php
RewriteRule ^([a-z0-9]+)/?$ /$1/innerpage.php
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /$1/$2/innerpage.php
RewriteRule ^innerpage.php$ / [R]
RewriteRule ^([a-z0-9]+)/innerpage.php$ /$1 [R]
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/innerpage.php$ /$1/$2 [R]
And be surprise what will happened...
I have the following .htaccess config
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteRule \.git - [F,L]
RewriteRule ^help help.php [L]
RewriteRule ^home home.php [L]
RewriteRule ^profile profile.php [L]
RewriteRule ^index index.php [L]
RewriteRule ^users/([0-9]+) profile.php?id=$1 [L]
RewriteRule ^([A-Za-z0-9-]+)?$ profile.php?u=$1 [L]
Now, whenever somebody visits the landing page, they get redirected using the last rule for profile.php?u=$1.
How do I change the configuration so that www.example.com and www.example.com/ are mapped to index.php and not profile.php?
Match the empty string or single slash just after the ^index rule:
RewriteRule ^help help.php [L]
RewriteRule ^home home.php [L]
RewriteRule ^profile profile.php [L]
RewriteRule ^index index.php [L]
# Match root request with optional slash
RewriteRule ^/?$ index.php [L]
I will suggest not to do it this way.
Instead, simply user this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
This will send all your requests to index.php page, from there create a router.php and pass on the requests to that page, using php.
but in case you do, just add
RewriteRule ^/?$ index.php [L]
Like Michael suggested.
Here is a simple tool to test your rules, if you wish to
Apache RewriteRule tester