.htaccess

Remove all folder name form url

☆樱花仙子☆ 提交于 2021-02-05 09:18:30
问题 Recently I have installed my site into a sub-folder of root of server. So To remove folders name from URL i have used following htaccess code. Options -Indexes RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?hostname.com$ RewriteRule ^(/)?$ user/site1/index.php [L] But the problem is that i am, also able to access my site Via hostname.com/user/site1 How can i stop user accessing my site via "hostname.com/user/site1" Please help 回答1: You can have a new redirect rule for this: Options

Remove all folder name form url

泄露秘密 提交于 2021-02-05 09:18:26
问题 Recently I have installed my site into a sub-folder of root of server. So To remove folders name from URL i have used following htaccess code. Options -Indexes RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?hostname.com$ RewriteRule ^(/)?$ user/site1/index.php [L] But the problem is that i am, also able to access my site Via hostname.com/user/site1 How can i stop user accessing my site via "hostname.com/user/site1" Please help 回答1: You can have a new redirect rule for this: Options

Date and name based friendly URL using .htaccess

大城市里の小女人 提交于 2021-02-05 09:04:49
问题 I'm planning on switching from having my blog on wordpress.com to having it on my own site hosted on my own server. Naturally I want to preserve the link structure from wordpress so that no links to my blog out there on the WWW break. So my question is, how do I get the following friendly URL http://example.com/yyyy/mm/dd/post-name to map to some structure like http://example.com/index.php?page=bla-bla on my server using .htaccess? Can the identifier bla-bla be a simple integer id, or does it

Date and name based friendly URL using .htaccess

萝らか妹 提交于 2021-02-05 09:02:29
问题 I'm planning on switching from having my blog on wordpress.com to having it on my own site hosted on my own server. Naturally I want to preserve the link structure from wordpress so that no links to my blog out there on the WWW break. So my question is, how do I get the following friendly URL http://example.com/yyyy/mm/dd/post-name to map to some structure like http://example.com/index.php?page=bla-bla on my server using .htaccess? Can the identifier bla-bla be a simple integer id, or does it

Order of RewriteRules in an htaccess file

做~自己de王妃 提交于 2021-02-05 08:49:27
问题 In an htaccess file, is it necessary that the rewrite rules follow an order? Like, long ones first and shorter ones last or something like that? Or, is it ok to put them in any order. I only have a few rules like the ones below (some 20), but it's all a big mess. RewriteRule ^/?(backend)/(users)/(new|blocked)/([a-z0-9]+)/?$ /blah/users/index.php?type=$2&case=$3&offset=$4 [NC,L] 回答1: Ordering of rewrite rules is very important in .htaccess . You need to put most specific ones at the top and

Redirect www. to non-www and redirect all http to https with .htaccess

橙三吉。 提交于 2021-02-05 07:44:28
问题 Million times asked question, but after reading many of the answers here on SO I still can't figure this out. I need to redirect all requests like below: http://domain.tld > https://domain.tld http://www.domain.tld > https://domain.tld https://www.domain.tld > https://domain.tld http://sub.domain.tld > https://sub.domain.tld (when .htaccess placed in subdomain folder) Until now, I was using the code from html5boilerplate, that solved www to non-www <IfModule mod_rewrite.c> RewriteCond %{HTTPS

Pretty URL for .html with parameters

北战南征 提交于 2021-02-05 07:10:29
问题 I have a website which consists only from .html frontend and I want to have pretty URLs. My goal is to create something like this http://test.com/mypage.html => http://test.com/mypage http://test.com/mypage1.html => http://test.com/mypage1 and for one specific page http://test.com/my-prettlink.html?id=1 => http://test.com/my-prettlink/1 I tried this .htaccess which is located in project root but only removing .html works. Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine

Laravel .htaccess subfolder

送分小仙女□ 提交于 2021-02-04 08:27:07
问题 I now have a Laravel installation with the default folder structure. In my root folder I have a .htaccess file like this one. Options +FollowSymLinks <IfModule mod_rewrite.c> # RewriteEngine On # RewriteCond %{REQUEST_FILENAME} !-d # RewriteCond %{REQUEST_FILENAME} !-f # RewriteRule ^ index.php [L] RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] </IfModule> I have to install in a subfolder WordPress. So I would like to access to my WP installation using the URL http://www.example.com/ and

Using Rewritebase in .htaccess

ぃ、小莉子 提交于 2021-01-29 22:02:11
问题 I'm using a .htaccess to redirect all calls to http://domain/site1/api/ to index.php in /site1/api/ folder. This index.php is the entry point for a rest api. # /site1/api/.htaccess RewriteEngine On RewriteBase /site1/api/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [QSA,L] It works fine, but is there a better way than use a hard coded RewriteBase? I would like to this two urls work: http://site1.domain/api/ and http://domain/site1/api/. 回答1:

How to find subdomain from a url

孤者浪人 提交于 2021-01-29 20:15:47
问题 URL = http://company.website.com/pages/users/add/ How do i find the subdomain from this via PHP Such that $subdomain = 'company' And $url = '/pages/users/add/' 回答1: You'll want to take a look at PHP's parse_url. This will give you the basic components of the URL which will make it easier to parse out the rest of your requirements (the subdomain) $url = 'http://company.website.com/pages/users/add/'; $url_parsed = parse_url($url); $path = $url_parsed['path']; // "pages/users/add/" And then a