my URL is like this.
http://site.org/index.php?page=tags&tag=tagname
I'd like to rewrite it to
http://site.com/tags/tagname
My current .htaccess
RewriteEngine On
# RewriteRule ^/?([a-z]+)$ $1.php [L]
RewriteEngine on
RewriteRule ^([A-Za-z0-9-_]+)$ index.php?paste=$1 [L]
RewriteEngine on
RewriteRule ^([A-Za-z0-9-_]+)/edit$ index.php?paste=$1&page=edit [L]
RewriteEngine on
RewriteRule ^([A-Za-z0-9-_]+).txt$ index.php?paste=$1&paste_txt=$1 [L]
RewriteEngine on
RewriteRule ^([A-Za-z0-9-_]+).txt$ index.php?paste=$1&paste_txt=$1 [L]
RewriteEngine on
RewriteRule ^([A-Za-z0-9-_]+)/delete$ index.php?paste=$1&page=delete [L]
RewriteEngine on
RewriteRule ^([A-Za-z0-9-_]+).download$ index.php?paste=$1&paste_download=$1 [L]
RewriteEngine on
RewriteRule ([^/\.]+)/?.cgi$ index.php?page=$1 [L]
#RewriteEngine on
#RewriteRule ([^/\.]+)/?.txt$ index.php?paste_txt=$1 [L]
#RewriteEngine on
#RewriteRule ([^/\.]+)/?.download$ index.php?paste_download=$1 [L]
RewriteRule ^/?([A-za-z0-9]+)/([A-za-z0-9]+)$ index.php?page=$1&tag=$2 [L]
I believe this should do it... That is if you want numbers in your tags. If not, remove the 0-9 from each part of it.
Related
My .htaccess file looks like this:
Options +FollowSymlinks
RewriteEngine On # Turn on the rewriting engine
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com%{REQUEST_URI} [R=301,L]
RewriteRule ^product/([0-9]+)/*. /tags.php?id=$1 [NC,L]
RewriteRule ^page/([a-zA-Z0-9_-]+)$ /site.php?page=$1 [NC,L]
I wanted the last rule to be:
RewriteRule ^site/([a-zA-Z0-9_-]+)$ /site.php?page=$1 [NC,L]
If I change the last rule, it does not work at all. I get a 404 not found.
I have no idea why it doesn't work, is the word 'site' a registered word or...?
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^files/(.*) files/index.php
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
I am trying to rewrite everything in the files directory to index.php which is also in the files directory. The page displays but always gives a 500 error , can anyone help me please ?
Do this in the same order:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/files [NC]
RewriteRule ^(files)/.* $1/index.php [L]
I am trying to configure a .htaccess file to my webpage to make it work as i want, but after a lot of searching and trying to understand the documentation, my head is just confused about these mod_rewrite.
It looks like this:
root/index.php
root/application/-subfolders-
root/config/-files-
root/library/-files-
what i want is everything sent to the index.php file as a parameter like index.php?page=$i, so i can have links like www.mypage.com/foo/bar and my index.php handles it.
ALSO i want to have the www.mypage.com/js/filename be sent to a subfolder in application,
like root/application/javascripts/filename.
I just cant get this to work, tried different answer i found both here and other places.
.htaccess at is now:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/js/ application/javascripts/ [L]
RewriteRule ^/js/(.*)$ application/javascripts/$1 [L]
RewriteRule ^css/ application/css/ [L]
RewriteRule ^css/(.*)$ application/css/$1 [L]
RewriteRule ^images/ application/images/ [L]
RewriteRule ^images/(.*)$ application/images/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php?page=$1 [NC]
</IfModule>
This should do it:
RewriteEngine on
RewriteRule ^js/(.*)$ application/javascripts/$1 [L]
RewriteRule ^css/(.*)$ application/css/$1 [L]
RewriteRule ^images/(.*)$ application/images/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?page=$1 [NC]
I have a website with Drupal installed in a subfolder /drupal. This instance needs to handle all URLs for the site, which it does successfully with the rules below:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^131.216.164.200:10011$ [NC]
RewriteRule .* http://131.216.164.200:10011/ [L,R=301]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal/index.php?q=$0 [QSA]
However, I now need to add another Drupal folder, /otherdrupal, which will handle only URLs beginning with /something1 or /something2. What I've tried is modifying the rules to this:
RewriteCond %{HTTP_HOST} !^131.216.164.200:10011$ [NC]
RewriteRule .* http://131.216.164.200:10011/ [L,R=301]
RewriteRule ^(something1|something2)$ otherdrupal/index.php [L]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{DOCUMENT_ROOT}/otherdrupal%{REQUEST_URI} -f
RewriteRule .* otherdrupal/$0 [L]
But mod_rewrite is not gonna make it that easy...
(P.S. I'm aware of Drupal's multi-site feature, but assume that the second Drupal instance may be any web application that handles URLs the same way as Drupal does, e.g. with a q URL parameter.)
I figured it out. My working .htaccess file:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^131.216.164.200:10011$ [NC]
RewriteRule .* http://131.216.164.200:10011/ [L,R=301]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{REQUEST_URI} ^(/something1|/something2)
RewriteRule .* otherdrupal/index.php?r=$1 [L,QSA]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal/index.php?q=$0 [QSA]
I need to make rules for mod_rewrite:
from
http://site.kiev.ua/index.php
http://www.site.kiev.ua/
http://www.site.kiev.ua/index.php
to
http://site.kiev.ua/
from
http://site.kiev.ua/catalog/products/941
to
http://site.kiev.ua/catalog/products/941/
from
http://site.kiev.ua/catalog/products/941/index.php
to
http://site.kiev.ua/catalog/products/941/
941 - it may be any category
RewriteEngine On
RewriteBase /
# www to none www
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
# Remove index.php
RewriteCond %{THE_REQUEST} \ /(.+/)?index\.(html?|php)(\?.*)?\ [NC]
RewriteRule ^(.+/)?index\.(html?|php)$ ./$1 [R=301,L]
# Force trailing slashes.
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
# /file.php to /file/
RewriteCond %{REQUEST_URI} ^(/.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule ^([^/]+)/?$ ./$1.php [QSA,L]
Options +FollowSymlinks -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.site\.kiev\.ua$ [NC]
RewriteRule ^(.*)$ http://site.kiev.ua/$1 [L,R=301]