.htaccess

.htaccess redirect variable to friendly link - many redirects

廉价感情. 提交于 2020-01-06 05:21:06
问题 I have a problem with htaccess redirecting a variable to clean url. the code: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php?page=$1 [R] RewriteCond %{QUERY_STRING} ^page=about$ RewriteRule ^(.*)$ https://www.url.com/about? [R=301,L] i just want to redirect this: "?page=about" to this: "/about" and with the code above give me to many redirects... Thanks for the time to look at this. 回答1: So i have tried your code in an empty directory on

htaccess code not working when i move my files in subfolder

谁说我不能喝 提交于 2020-01-06 04:49:27
问题 I am trying to move my project files from the root folder to subfolder. Now all files are in subfolder. I have this following htaccess code: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase /project/ ErrorDocument 404 http://localhost/404.php RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC] RewriteRule ^ /%1 [R=302,NE,L] RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{THE_REQUEST} /index\.php [NC] RewriteRule ^(.*)index\.php$ /$1 [L,R

Multiple conflicting htaccess RewriteRules

南楼画角 提交于 2020-01-06 04:31:08
问题 I'm trying to have both people's profiles at example.com/Sara and a few special pages like example.com/home and /account. How do I make both of my RewriteRules work? Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ ./people.php?s=$1 RewriteRule ^home ./home.php Thanks! Edit: Figured it out...! Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f

Use PHP to rewrite URLS?

血红的双手。 提交于 2020-01-06 04:30:34
问题 I want to make my own url rewriting rules using couple of PHP-MySQL. The concept is to have a rule in my .htaccess that send all request to my index.php file like : RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php RewriteCond %{REQUEST_URI} !\.(.+)$ RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]. And php will take all params via a super global var like $_SERVER['REQUEST_URI'] and explode("/", $_SERVER['REQUEST_URI']) . function rewrite(){ $paramKeys = array("", "locale", "page", "par1"

How to redirect site to 403 if a certain url get variable exists or contains an unwanted value using htaccess

╄→尐↘猪︶ㄣ 提交于 2020-01-06 04:19:06
问题 In my site statistics, I'm staring to get strange URLs like these: mysite.com/?p=casino-online-spielen mysite.com/category/page/2/?p=casino-online-spielen I've tried rewrites but it has messed up my WordPress rewrites or just didn't work. I am not that good in htaccess or apache. <IfModule mod_alias.c> RedirectMatch 403 ?p=(casino|pharmacy) </IfModule> What I need is a htaccess rule that sends the user to 403 error if the word casino is found, or better yet if ?p= is found in the URL, which

How do I force HTTPS (Cloudflare Flexible SSL)?

孤街浪徒 提交于 2020-01-06 04:11:14
问题 I am using Cloudflare Flexible SSL on a website I programmed myself (no framework or CMS). Everything is working and now I want to use HTTPS on the whole site. I use PHP on Apache web server. I am wondering how I should approach this and redirect all users to HTTPS. Currently my .htaccess is set up like this: # Force www. RewriteCond %{HTTP_HOST} ^example\.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] I have seen this answer on stackoverflow, but it points to another answer

How do I force HTTPS (Cloudflare Flexible SSL)?

情到浓时终转凉″ 提交于 2020-01-06 04:11:08
问题 I am using Cloudflare Flexible SSL on a website I programmed myself (no framework or CMS). Everything is working and now I want to use HTTPS on the whole site. I use PHP on Apache web server. I am wondering how I should approach this and redirect all users to HTTPS. Currently my .htaccess is set up like this: # Force www. RewriteCond %{HTTP_HOST} ^example\.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] I have seen this answer on stackoverflow, but it points to another answer

Subdomains rewrite .htaccess

我的未来我决定 提交于 2020-01-06 04:04:11
问题 I have these rules, everything work good. I just need to add this rule: from it.domain.org/index.php?city=newyork to it.domain.org/product-usa-newyork The only thing that change is "newyork". It can be also: lasvegas etc.. 回答1: Try inserting these 2 rules before your existing rules : #Rewrite from http://it.domain.org/index.php?city=dc to http://it.domain.org/product-usa-dc RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.org$ [NC] RewriteCond %{THE_REQUEST} \s/

Set redirect in .htaccess for all the urls with a suffix

一曲冷凌霜 提交于 2020-01-06 03:45:29
问题 I have the urls like: example.com/vm-search/parentcategory-cityname/childcategory-cityname They are indexed by search engines. I decided to remove the cityname suffix from all the parentcategories and now I need to set redirect from all the old urls to new ones before the search engines will index them. The citynames are the same for all the urls and the new urls will be like: example.com/vm-search/parentcategory/childcategory-cityname I haven't try anything with htaccess yet. What rule

How to keep URI in the browser using ErrorDocument in .htaccess?

泪湿孤枕 提交于 2020-01-06 03:44:25
问题 I have a simple 404 error redirect in the .htaccess to my script like this: ErrorDocument 404 https://example.com/error.pl?q=404 But on the redirect the address is changed in the address bar of the browser to this https://example.com/error.pl?q=404 from the wrong address (from which the redirect is performed). How to keep the initial address in the browser address bar while redirecting to the custom error page? Your kind help is highly appreciated! 回答1: Use link without domain name: