url-rewriting

Base URL in .htaccess

不问归期 提交于 2019-12-18 06:54:17
问题 I wonder if this is possible to tell via .htaccess or any other manners to set a base URL. Example My CSS in the index.php is set like this <link rel="stylesheet" href="css/style.css"/> Everything works fine when i'm on the first directory to load my file and pages. But when I have a page set in a folder like /page/index.html. The css isn't loaded because the folder is not in page/ but in the root directory. So is that possible to tell it to look always from the root directory to load the CSS

Removing .php file extension with .htaccess file

自闭症网瘾萝莉.ら 提交于 2019-12-18 05:54:51
问题 I want www.example.com/about.php to just be www.example.com/about I created an .htaccess file and placed it in the root of my server. I am using linux shared hosting. PHP version 5.2 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php It seems that this code should work properly, but for some reason it does not. I get a 404 error when I try to navigate to a page without the .php extension. Here's my markup too: <nav> <div

need to escape # (hash/pound) character in .htaccess rewrite rule

寵の児 提交于 2019-12-18 05:44:14
问题 The question is fairly simple but I was not able to find an answer for hours now. What I need to do is: RewriteRule ([^#])#(.*) $1\%23$2 Which basically means I want to url escape the freaking hash sign which comes to me from an external codepiece. backslash ( \ ) does not work to escape this sign... and please don't suggest using %23 instead # because it does not work as well. ( %2 3 does not match a # because it simply is not == %23 ) 回答1: The hash part of a URL is not available for

Temporary file download link with ASP.NET

随声附和 提交于 2019-12-18 05:16:06
问题 I'd like to know how I can generate a temporary download address for my file for a limited time. I know that's not the best practice and probably using HttpHandlers is the way to go according to http://www.devx.com/codemag/Article/34535/1954 But I'm curious to know how I can use urlrewriting to generate a file name using a GUID or some other cryptic naming technique and make it available for a limited time. I'd appreciate if anyone points me a good article about it. 回答1: Well first you need

Remove index.php from wordpress URLs in iis7

有些话、适合烂在心里 提交于 2019-12-18 04:16:28
问题 I want to remove index.php from url , i am using wordpress and iis7 . how can i do this 回答1: Use this web.config (web.config is the IIS equivalent to .htaccess file in apache webservers. It can be found in the root folder. If there is none, you need to create one.) <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <defaultDocument> <!-- Set the default document --> <files> <remove value="index.php" /> <add value="index.php" /> </files> </defaultDocument> <httpErrors

IIS7 URL Rewriting: How not to drop HTTPS protocol from rewritten URL?

梦想与她 提交于 2019-12-17 23:29:27
问题 I'm working on a website that uses IIS 7's URL rewriting feature to do a permanent redirect from example.com to www.example.com, as well as rewrites from similar domain names to the "main" one, such as from www.examples.com to www.example.com. This rewrite rule - shown below - has worked well for some time now. However, we recently added HTTPS support and noticed that if users visit one of the URLs to be rewritten to www.example.com then HTTPS is dropped. For instance, if a user visits https:

Azure CDN rules engine to rewrite default document and remove .html extension

喜夏-厌秋 提交于 2019-12-17 23:15:01
问题 I would like to use azure blob and CDN premium features but the documentation is very sparse . This is something totally doable on Amazon S3 / CloudFront. For clarity I want *.azureedge.net/sample/index.html to equal *.azureedge.net/sample/ and *.azureedge.net/sample/test.html to equal to *.azureedge.net/sample/test This is totally not clear and takes "up to 4 hours" to preview changes, so... After some investigation, Azure has a wrapper for Verizon Edgecast CDN, and this page looks identical

ASP.NET MVC UrlHelper.GenerateUrl exception: “Cannot use a leading .. to exit above the top directory”

坚强是说给别人听的谎言 提交于 2019-12-17 23:11:54
问题 I am using the IIS 7 Rewrite module to rewrite an incoming url like: http://server/year/all to http://server/application/controller/year/all Everything works fine, except when, while processing the rewritten request, I use MVC's UrlHelper.GenerateUrl() method: UrlHelper.GenerateUrl( "Assets", "Css", "Asset", new RouteValueDictionary(new { site = site.Name, assetPath = assetPath }), RouteTable.Routes, controllerContext.RequestContext, false); Calling this method results in an HttpException:

RewriteRule Error: Bad flag delimiters

蓝咒 提交于 2019-12-17 22:56:48
问题 Using this RewriteRule in my .htaccess file I'm getting RewriteRule: Bad flag delimiters which is returning a 500 error in the browser. Can anyone point me in the right direction please. Thanks. RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^dev/(.*)$ http://dev.example.com/$1 [L,R=301, NC] This is on Ubuntu on a Digital Ocean Droplet. 回答1: Turns out it was because of the space before N in the flag declaration [L,R=301, NC]. I changed it to [L,R=301,NC] and now it

NGINX - Return 301 vs Rewrite

房东的猫 提交于 2019-12-17 22:17:44
问题 I use NGINX in my dedicated server. I've a question about the return and rewrite 301 . Rewrite 301: rewrite ^ http://xxx.xxxxx.net/xx-xxx/$request_uri? permanent; Return 301: location ~ redirect-this/?$ { return 301 http://xxx.xxxxx.net/xx-xxx/redirect-this$1; } All redirects work correctly. But.. Which is the most effective method to make a 301 redirect? I've more than 200 url to redirect. So, what you recommend? 回答1: As stated in the nginx pitfalls you should use server blocks and return