.htaccess

url rewriting with htaccess? [duplicate]

痞子三分冷 提交于 2020-01-04 11:04:00
问题 This question already has an answer here : rewrite url with htaccess [closed] (1 answer) Closed 5 years ago . My problem: I want to write a .htaccess rule for. www.asdf.com/city.php?city=New-York to www.asdf.com/New-York but also with that I have other pages such as www.asdf.com/country.php?country=USA which I would like to appear as www.asdf.com/USA and www.asdf.com/state.php?country=LA which I would like to appear as www.asdf.com/LA Pretty confused how to do that. 回答1: If you wish to have

.htaccess path only accessible by ip

安稳与你 提交于 2020-01-04 11:02:34
问题 I would like to block a path from my site using the .htaccess configuration. The idea is that only a specific set of IP's can access that specific path from the URL. Note: It's a path, not a page or directory. We are trying to shield off a web-service so there will be only post calls to the URL's. I would like the url example.com/rest to be blocked and everything behind that url based on IP. So example.com/rest/test_service and example.com/rest/test_service/read should be blocked. All other

.htaccess path only accessible by ip

大兔子大兔子 提交于 2020-01-04 11:01:53
问题 I would like to block a path from my site using the .htaccess configuration. The idea is that only a specific set of IP's can access that specific path from the URL. Note: It's a path, not a page or directory. We are trying to shield off a web-service so there will be only post calls to the URL's. I would like the url example.com/rest to be blocked and everything behind that url based on IP. So example.com/rest/test_service and example.com/rest/test_service/read should be blocked. All other

htaccess returning 500 error when needs to be 404

家住魔仙堡 提交于 2020-01-04 10:44:11
问题 How can I make it so that my htaccess rules return a 404 when invalid urls are entered into the address bar. The two rules that are causing this RewriteRule ^submit/([a-z]+)/([0-9]+)$ /submit?c=$1&i=$2 [L] RewriteRule ^test/([a-z]+)/([0-9]+)/([0-9]+)$ /test?c=$1&i=$2&q=$3 [L] Both the rules work fine when a correct url is entered but say for example one of the last parameters is not a number, it returns a 500 error. How can I make it so that if these rules are not matched then it'll return a

<filesmatch> for only one page

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 10:00:06
问题 I have a need to have only the home page have the following Filesmatch where .pdf files need to ask before opening up, but other .pdf files in the site (not on the home page) I want to open automatically. Is this the best way to accomplish this? This is a Wordpress site, latest version, and the home page is a set page. Also, the owner of the site could add more .pdf links within the site so I don't want to complicate it too much where she has to manipulate code every time she adds a file.

How to prevent IDM capturing MP3 files?

半世苍凉 提交于 2020-01-04 09:27:31
问题 I use the following code to add a Music player in my site, <div id="player" style="z-index:100;"></div><!--Player--> <script language="javascript" type="text/javascript"> var so = new SWFObject("flashmp3player.swf", "player", "242", "150", "9"); // Location of swf file. You can change player width and height here (using pixels or percents). so.addParam("quality", "high"); so.addParam("wmode", "opaque"); so.addVariable("content_path","<? echo $playerpath; ?>"); so.addVariable("color_path",

Laravel 4 pagination not working links are OK but shows all results in each page

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-04 06:38:06
问题 In a fresh installation with composer of Laravel 4 in windows 7 I have in routes.php: Route::model('work', 'Work'); Route::get('/', function() { $works = Work::all(); $allWorks = Work::paginate(5); return View::make('hello', compact('works', 'allWorks')); }); And in view file 'hello.php': <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Laravel PHP Framework</title> </head> <body> <div class="container"> <?php foreach ($works as $work) { echo $work->title . '<br/>'; } ?>

Phalconphp routes not working

大憨熊 提交于 2020-01-04 06:06:26
问题 I'm new to phalconphp and following their tutorials, as far as I understand it, I don't need to create a specific routing component and that it should pick up a route if it exists. I could obviously be massively wrong here which means it should be easy to correct me! But so far the only controller that will work is my indexController. This is my bootstrap <?php try { //Register an autoloader $loader = new \Phalcon\Loader(); $loader->registerDirs(array( '../app/controllers/', '../app/models/'

Retain query string on rewrite .htaccess

一世执手 提交于 2020-01-04 06:00:56
问题 I currently have a simple rewrite that redirects /photos/2 to /photoviewer.php?photo=2 However I need to be able to allow the user to add a photo to their cart so I was thinking I need to retain the query string so that the following works. /photos/2?action=purchase redirects to: /photoviewer.php?photo=2&action=purcahse My current htaccess rule is: RewriteRule ^photos/([a-zA-Z0-9_-]+)$ photoviewer.php?photo=$1 [L] 回答1: Append the [QSA] flag (query string append). RewriteRule ^photos/([a-zA-Z0

Check if header is present in request with apache

人盡茶涼 提交于 2020-01-04 05:45:08
问题 How can I check if a header exist. I dont want to check if the value is different of "" I want to check if it really exist using: RewriteCond How can I do that inside htaccess file? 回答1: You can use a condition like this to know if a header X-SomeHeader exists or not: RewriteEngine On # block if request header X-SomeHeader doesn't exist RewriteCond %{HTTP:X-SomeHeader} !^$ RewriteRule ^ - [F] 回答2: @anhubhava's answer was useful but logic inverted! it should be: RewriteEngine On # block if