简体   繁体   中英

Mod Rewrite in Mac OSX Sierra

I am having issues with mod_rewrite when trying to route all calls to one directory to one single script in that directory. This simple rule was working on linux:

RewriteRule * api.cgi

In the error log on this OS, for this I get "RewriteRule: cannot compile regular expression '*'".

I've tried a few other things, and mod rewrite is working on some matches, but only on filenames and not the directory paths.

Eg. RewriteRule .* api.cgi - routes anything with a filename to api.cgi which proves it is working, but I want to route /api/config/ to api.cgi. I can only seem to get /api/config/something.something to actually force the rewrite - ie it needs a filename.

Any ideas? I literally want to route absolutely everything called in this directory to api.cgi, no matter how many directories deep or whether or not it has a filename at the end of it.

Thanks, Matt

You can use:

RewriteRule ^ api.cgi

But normally the result is exactly the same with

RewriteRule .* api.cgi

If you have done many tests, it is possible that it is a cache problem. Try to clear your cache or with another browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM