I have a two-part site, the first part on the home page, I have one .htaccess file and I use these htaccess commands to rewrite their files
RewriteRule ^sitemap-([0-9]+).xml$ sitemap-xml.php?page=$1
The other part of the site is on folder called bio, and i use these htaccess commands to rewrite their files
RewriteRule ^/bio/([0-9]+)/(.*)$ /bio/show_person.php?id=$1&url=$2 [QSA,L]
but the bio RewriteRule dose not work, how can i fix it
here is my complete htaccess
RewriteEngine On
RewriteBase /bio/
RewriteRule ^([0-9]+)/(.*)$ show_person.php?id=$1&url=$2 [QSA,L]
RewriteRule ^job-([0-9]+)/$ show_job.php?id=$1 [QSA,L]
RewriteRule ^nationality-([0-9]+)/$ show_nationality.php?id=$1 [QSA,L]
RewriteRule ^borg-([0-9]+)/$ show_borg.php?borg=$1 [QSA,L]
RewriteRule ^birth-([0-9]+)-([0-9]+)/$ show_birthday.php?day=$1&month=$2 [QSA,L]
RewriteRule ^birthyear-([0-9]+)/$ show_birthyear.php?year=$1 [QSA,L]
RewriteRule ^death-([0-9]+)-([0-9]+)/$ show_deathday.php?day=$1&month=$2 [QSA,L]
RewriteRule ^deathyear-([0-9]+)/$ show_deathyear.php?year=$1 [QSA,L]
RewriteRule ^job-([0-9]+)/page/([0-9]+)$ show_job.php?id=$1&page=$2 [QSA,L]
RewriteRule ^nationality-([0-9]+)/page/([0-9]+)$ show_nationality.php?id=$1&page=$2 [QSA,L]
RewriteRule ^borg-([0-9]+)/page/([0-9]+)$ show_borg.php?borg=$1&page=$2 [QSA,L]
RewriteRule ^birth-([0-9]+)-([0-9]+)/page/([0-9]+)$ show_birthday.php?day=$1&month=$2&page=$3 [QSA,L]
RewriteRule ^birthyear-([0-9]+)/page/([0-9]+)$ show_birthyear.php?year=$1&page=$2 [QSA,L]
RewriteRule ^death-([0-9]+)-([0-9]+)/page/([0-9]+)$ show_deathday.php?day=$1&month=$2&page=$3 [QSA,L]
RewriteRule ^deathyear-([0-9]+)/page/([0-9]+)$ show_deathyear.php?year=$1&page=$2 [QSA,L]
RewriteRule ^page/([0-9]+)$ index.php?page=$1 [QSA,L]
RewriteRule ^sitemap-([0-9]+).xml$ sitemap.php?page=$1
Place this rule in bio/.htaccess:
RewriteEngine On
RewriteBase /bio/
RewriteRule ^(\d+)/(.*)$ show_person.php?id=$1&url=$2 [QSA,L]
Related
I have a core PHP website that is hosted over a server and now I have moved the website to a subfolder to access the website something like that example.com/site. that website also use the .htaccess for managing multiple language.but after moving it to subfolder website is not accessible. Please see the following .htaccess file. This .htaccess is when the website is on root folder I want this .htacess to work when on subfolder /site/ please help me.
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*) https://www.example.com/$1 [L,R=301]
<IfModule mod_rewrite.c>
# URL rewriting module activation
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^en/([^?&]*)$ /$1?lang=en [QSA,L]
RewriteRule ^en/privacy-policy$ /privacy-policy.php?lang=en [QSA,L]
RewriteRule ^en/legal-notice$ /legal-notice.php?lang=fr [QSA,L]
RewriteRule ^fr/politique-de-confidentialite$ /privacy-policy.php?lang=fr [QSA,L]
RewriteRule ^fr/mentions-legales$ /legal-notice.php?lang=fr [QSA,L]
RewriteRule ^fr/([^?&]*)$ /$1?lang=fr [QSA,L]
</IfModule>
You may try these rules in /site/.htaccess:
RewriteEngine On
# add www and turn on https in same rule
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^en/privacy-policy/?$ privacy-policy.php?lang=en [QSA,L]
RewriteRule ^en/legal-notice/?$ legal-notice.php?lang=fr [QSA,L]
RewriteRule ^fr/politique-de-confidentialite/?$ privacy-policy.php?lang=fr [QSA,L]
RewriteRule ^fr/mentions-legales/?$ legal-notice.php?lang=fr [QSA,L]
RewriteRule ^(en|fr)/(.*)$ $2?lang=$1 [QSA,L]
You can add
RewriteBase /site/
then write the conditions like
RewriteRule ^site/en/privacy-policy/?$ site/privacy-policy.php?lang=en [QSA,L]
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
Im trying to change my urls from mywebsite.co/keyword to mywebsite.co/web/keyword i found a few ways to do this but it always causes problems with my other rewrites here is what i have so far only problem with it is it wont redirect mywebsite.co/keyword to mywebsite.co/web/keyword
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^screenshot/ - [L]
# If requested resource exists as a file or directory, skip next two rules
RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule (.*) - [S=2]
# when there is no space make an external redirection
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^info/([0-9a-zA-Z]+) /search/info/info.php?keyword=$1 [QSA,L]
RewriteRule ^web/([0-9a-zA-Z]+) /search/web/index.php?search=$1 [QSA,L]
RewriteRule ^videos/([0-9a-zA-Z]+) /search/video/video.php?keyword=$1 [QSA,L]
RewriteRule ^images/([0-9a-zA-Z]+) /search/images/image.php?keyword=$1 [QSA,L]
RewriteRule ^news/([0-9a-zA-Z]+) /search/news/news.php?keyword=$1 [QSA,L]
RewriteRule ^products/([0-9a-zA-Z]+) /search/products/product.php?keyword=$1 [QSA,L]
RewriteRule ^maps/([0-9a-zA-Z]+) /search/maps/maps.php?keyword=$1 [QSA,L]
RewriteRule ^space/([0-9a-zA-Z]+) /search/space/space.php?keyword=$1 [QSA,L]
RewriteRule ^web/ /search/web/index.php [QSA,L]
RewriteRule ^info/ /search/info/info.php [QSA,L]
RewriteRule ^videos/ /search/video/video.php [QSA,L]
RewriteRule ^images/ /search/images/image.php [QSA,L]
RewriteRule ^news/ /search/news/news.php [QSA,L]
RewriteRule ^products/ /search/products/product.php [QSA,L]
RewriteRule ^maps/ /search/maps/maps.php [QSA,L]
RewriteRule ^space/ /search/space/space.php [QSA,L]
Have it this way:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^screenshot/ - [L]
# If requested resource exists as a file or directory, skip next two rules
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^info/([0-9a-zA-Z]+)/?$ /search/info/info.php?keyword=$1 [QSA,L]
RewriteRule ^web/([0-9a-zA-Z]+)/?$ /search/web/index.php?search=$1 [QSA,L]
RewriteRule ^videos/([0-9a-zA-Z]+)/?$ /search/video/video.php?keyword=$1 [QSA,L]
RewriteRule ^images/([0-9a-zA-Z]+)/?$ /search/images/image.php?keyword=$1 [QSA,L]
RewriteRule ^news/([0-9a-zA-Z]+)/?$ /search/news/news.php?keyword=$1 [QSA,L]
RewriteRule ^products/([0-9a-zA-Z]+)/?$ /search/products/product.php?keyword=$1 [QSA,L]
RewriteRule ^maps/([0-9a-zA-Z]+)/?$ /search/maps/maps.php?keyword=$1 [QSA,L]
RewriteRule ^space/([0-9a-zA-Z]+) /search/space/space.php?keyword=$1 [QSA,L]
RewriteRule ^web/?$ /search/web/index.php [QSA,L]
RewriteRule ^info/?$ /search/info/info.php [QSA,L]
RewriteRule ^videos/?$ /search/video/video.php [QSA,L]
RewriteRule ^images/?$ /search/images/image.php [QSA,L]
RewriteRule ^news/?$ /search/news/news.php [QSA,L]
RewriteRule ^products/?$ /search/products/product.php [QSA,L]
RewriteRule ^maps/?$ /search/maps/maps.php [QSA,L]
RewriteRule ^space/?$ /search/space/space.php [QSA,L]
in typo3 htacces finish all redirection by RewriteRule .* index.php [QSA],
but I need create PromoCode foldier with php aplication and own index.php work under adres www.domainname.com/PromoCode. So i need to add exception into htacces, but not sure how...
RewriteRule ^rss\/([^\.]+).xml$ fileadmin/rss/$1.xml [QSA,L]
#RewriteRule ^fileadmin\/(.*)$ fileadmin/$1 [QSA,L]
# SPECIAL
RewriteRule ^ua-ru/links807835.php fileadmin/links807835.php [QSA,L]
# PAGING
RewriteRule ^(.*)(?!order\/.*)\/order\/([^-]+)-([^\/]+)(.*)$ $1$4?pg_order=$2&pg_by=$3 [QSA,L]
RewriteRule ^(.*)(?!order\/.*)\/order\/([^\/]+)(.*)$ $1$3?pg_order=$2 [QSA,L]
RewriteRule ^(.*)(?!page\/.*)\/page\/([^\/]+)(.*)$ $1$3?pg_page=$2 [QSA,L]
RewriteRule ^(.*)(?!size\/.*)\/size\/([^\/]+)(.*)$ $1$3?pg_size=$2 [QSA,L]
# FAQ
RewriteRule ^(.*)(?!faq\/.*)\/faq\/([^\/]+)(.*)$ $1$3?faq=$2 [QSA,L]
# GALLERY
RewriteRule ^(.*)(?!gallery\/.*)\/gallery\/([^\/]+)(.*)$ $1$3?gallery=$2 [QSA,L]
# ARTICLE
RewriteRule ^(.*)(?!article\/.*)\/article\/([^\/]+)(.*)$ $1$3?article=$2 [QSA,L]
# PRODUCT
RewriteRule ^(.*)(?!product\/.*)\/product\/([^\/]+)(.*)$ $1$3?product=$2 [QSA,L]
# EVENT
RewriteRule ^(.*)(?!event\/.*)\/event\/([^\/]+)(.*)$ $1$3?event=$2 [QSA,L]
# MATERIAL
RewriteRule ^(.*)(?!material\/.*)\/material\/([^\/]+)(.*)$ $1$3?material=$2 [QSA,L]
# CATEGORY
RewriteRule ^(.*)(?!category\/.*)\/category([^\/]+)([^\/]+)(.*)$ $1$3?category=$2 [QSA,L]
# LANGUAGE
RewriteRule ^([^\/]*)\/$ $1?id=$1 [QSA]
RewriteRule ^([^\/]*)$ $1?id=$1 [QSA]
#RewriteRule ^([^\/]*)[\/]{0,1}(.*)$ $2?lang=$1 [QSA]
RewriteRule ^([^\/]*)[\/]{0,1}(.*)$ ?lang=$1 [QSA]
# PAGE
RewriteRule ^[\/]{0,1}([^\/]+)[\/]([^\/]+)[\/]([^\/]+)[\/]{0,1}(.*)$ ?id=$3&pid1=$2&pid2=$1 [QSA]
RewriteRule ^[\/]{0,1}([^\/]+)[\/]([^\/]+)[\/]{0,1}(.*)$ ?id=$2&pid1=$1 [QSA]
RewriteRule ^[\/]{0,1}([^\/]+)[\/]{0,1}(.*)$ ?id=$1 [QSA]
# FINISH
RewriteCond %{REQUEST_URI} !^/PromoCode/
RewriteRule .* index.php [QSA]
Before the RewriteRule .* index.php line, add this condition:
RewriteCond %{REQUEST_URI} !^/promocode/
make the /promocode/ folder whatever the foldername is that you want to make an exception for.
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