mod-rewrite

.htaccess editing to hide folder from url & accessing main domain

早过忘川 提交于 2020-01-06 05:22:13
问题 i used a .htaccess editing to hide folder/directory from my website url. skynetbd.net/user_profile/login.php to skynetbd.net/login.php I used this: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+user_profile/([^\s]+) [NC] RewriteRule ^ %1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (?!^user_profile/)

Selectively redirect to a new domain using apache vhost configuration

☆樱花仙子☆ 提交于 2020-01-06 05:22:10
问题 This is a followup question on Redirect to a new domain using apache vhost configuration I want my requests from somedomain.com/loadproduct?product=dell-inspiron-15 to be redirected to someotherdomain.com/dell-inspiron-15 but selectively for some products which are whitelisted. For example for products : dell-inspiron-15. dell-inspiron-16. dell-inspiron-17 redirect to the new URL but for any other products I want to use the current path itself. Currently my vhost configuration looks like

Redirect from few url's (both www and non-www) to original one

北城以北 提交于 2020-01-06 05:02:52
问题 How to shorten this expression? i want instead of using 2 lines just check whatever domain is something different from mysite.com e.g. mysite.org or www.mysite.org with or without www and redirect. Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [OR] RewriteCond %{HTTP_HOST} ^mysite\.org$ [OR] RewriteCond %{HTTP_HOST} ^www\.mysite\.org$ [OR] RewriteCond %{HTTP_HOST} ^mysite\.net$ [OR] RewriteCond %{HTTP_HOST} ^www\.mysite\.net$ RewriteRule ^(.*)$ http:/

Hide or Change page extension with mod_rewrite

喜你入骨 提交于 2020-01-06 04:51:09
问题 how can i change all my php page to show as html page in the browser ? What will be the file name when they will save a x.php file ? 回答1: Try putting the following in a .htaccess file at the main directory of your site (public_html or www), or httpd.conf (or similar) if you aren't on shared hosting and have root access to the server: RewriteEngine On RewriteRule ^(.*)\.html$ $1.php When someone tries to save the page, it will save as .html (they will never know it was really a .php file!) 来源:

301 Redirect of old url with parameters to a path without parametes

不问归期 提交于 2020-01-06 04:45:10
问题 I need the following request : http://somesite.com/home.php?action=page&page_id=9 to trigger a 301 redirect to : http://somesite.com/a-new-page Here's what I'm using but it isn't working. RewriteCond %{QUERY_STRING} ^page_id=9$ [NC] RewriteRule ^home\.php$ http://somesite.com/a-new-page? [L,R=301] Any ideas? 回答1: If the QUERY_STRING will always be the same you need to match it like this: RewriteEngine on RewriteCond %{QUERY_STRING} ^action=page&page_id=9$ [NC] RewriteRule ^home.php$ http:/

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

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

.htaccess non-www to www and http to https

江枫思渺然 提交于 2020-01-06 02:50:12
问题 I know this question has been asked and answered many times but I've spent the last 3 hours going through peoples answers and none have seemed to work just right for me. I need some .htaccess code to do this: If domain is example.co.uk/$urlData (only apply to main domain and no subdomains) rewrite too www.example.co.uk/$urlData If HTTPS is not "on" and domain is primary (ie. no subdomains) then redirect to https://www.example.co.uk/$urlData . I have to use RewriteCond %{HTTP:X-Forwarded-Proto

How to redirect http to https and https://www to https://

时光怂恿深爱的人放手 提交于 2020-01-06 02:18:40
问题 I need help with rewrite rules. So I want that these addresses: http://domain.com http://www.domain.com https://www.domain.com Redirect to: https://domain.com Can someone help me? Right now I have rule: RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.com/$1 [R,L] But it doesnt redirect https://www to https:// 回答1: Place this rule in your DOCUMENT_ROOT/.htaccess file: RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} www\. RewriteRule ^ https://domain.com%