mod-rewrite

Apache mod_rewrite only if request does not start with '/THEMES/'

我与影子孤独终老i 提交于 2020-08-19 05:57:39
问题 I'm writing a CMS in PHP, and now I'm working at the themes feature. I have a .htaccess file: RewriteEngine ON RewriteRule ^([a-zA-Z][a-zA-Z0-9]*)$ index.php?m=$1 RewriteRule ^([a-zA-Z][a-zA-Z0-9]*)/(.+)$ index.php?m=$1&p=$2 If I have a request to: /page it must load the view function of the class called page. If I have a request to: /page/test it must load the view function of the class called page, with the parameter 'test'. This all works, But I want it to apply the RewriteRules ONLY if

Apache URL rewrite UUID v1

我与影子孤独终老i 提交于 2020-07-22 05:56:45
问题 How do you rewrite a 36 character v1 UUID precisely with maximal-checking using RewriteRule? UUID() returns a value that conforms to UUID version 1 as described in RFC 4122. The value is a 128-bit number represented as a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format: Please give something better than this: RewriteRule ^([A-z0-9\-]{36})$ index.php?uuid=$1 [L,QSA] 回答1: You may try: ^[a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}$ Explanation of the

Error 404 with Angular 4 using routing on Tomcat 9 with Valve

时光怂恿深爱的人放手 提交于 2020-07-20 03:58:27
问题 I'll tell you what happens by following steps: 1) I have my app project based on Angular 4.0.2. I'm using routing. These are my routes in app.module.ts: const routes: Routes = [ { path: '', component: LoginComponent }, { path: 'dashboard', component: DashboardComponent }, { path: 'login', component: LoginComponent } ]; So the first screen of the web application is Login. 2) I executed the command ng build -prod 3) I move the folder dist into Tomcat webapps folder 4) I modified the file index

How to serve webp images using htaccess?

…衆ロ難τιáo~ 提交于 2020-07-16 06:48:23
问题 I would like to serve .webp images if the image (jpg or png) is available as webp. If not I want to show the jpg or png. RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)\.(jpe?g|png)(.*)$ $1.$2.webp [NC,L] AddType image/webp .webp The problem I need the final URL to be like: "myurl.com/foo.jpg.webp" If the webp file exists and if not I need: "myurl.com/foo.jpg" as a fallback solution. 回答1: If the requested URL ends in jpeg or png , you might test for

Merge two .htaccess files from two projects into one

江枫思渺然 提交于 2020-06-28 03:45:21
问题 I have a project which I have to include within a project. So .. project A is a web site built on top of custom framework which uses this .htaccess rewrite rules: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?url=$1 [PT,L] The second project B is built on top of another custom framework and I am supposed to make it look like a subfolder to the first one. So I placed project B inside a folder "subfolder". Project B has its own .htaccess

What does the =$1 mean in url rewriting?

江枫思渺然 提交于 2020-06-26 14:49:09
问题 I can't find any information on stackoverflow or google about the meaning of =$1 . I get superficial information but nothing for beginners like me. What does it do? If I have something like this: www.website.com/profile.php?simon Does the name simon correspond to the $1 variable and why 1 ? This is how I understand it: (.*) profile/profile.php? id=$1 The bold corresponds to: www.website.com/profile.php? id=simon Converted with rewrite it becomes: www.website.com/profile/simon Am I missing

How to make WordPress use these URLs for a bilingual single-page website: /en/my-page-here or /ro/my-page-here?

谁说我不能喝 提交于 2020-06-23 18:37:39
问题 I will have a single-page website that will have URLs in the form of /en/my-page-here and /ro/my-page-here . The problem is that the rewrite rules make my http://localhost/ro/home redirect to http://localhost/home . If I am right then what can I do to correct these default lines in my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] <

How to make WordPress use these URLs for a bilingual single-page website: /en/my-page-here or /ro/my-page-here?

感情迁移 提交于 2020-06-23 18:37:05
问题 I will have a single-page website that will have URLs in the form of /en/my-page-here and /ro/my-page-here . The problem is that the rewrite rules make my http://localhost/ro/home redirect to http://localhost/home . If I am right then what can I do to correct these default lines in my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] <

HTTPS with redirection to other domain with apache virtual host

邮差的信 提交于 2020-06-17 09:36:46
问题 I would like to redirect a virtual host on my server to another domain, which is running on HTTPS. I also would like to only show the original url, hence using the P flag for proxy. Here is the current configuration : RewriteEngine on SSLProxyEngine on RewriteCond %{HTTP_HOST} ^subdomain1\.domain1\.ext1$ [NC] RewriteRule ^(.*) https://subdomain2.domain2.ext2$1 [L,R,P] Should I generate a certificate on domain1 with certbot? What webroot should I associate? Should I include the one from

mod_rewrite only on GET

雨燕双飞 提交于 2020-06-11 17:58:12
问题 It's a longshot, but I'm hoping to find a simple workaround for a bizarre bug that only manifests when the query string is omitted/inferred by the application. Before I dig deep into a thousand lines of minified 3rd party javascript, I'd like to find out if I can just auto apply the querystring using mod_rewrite. RewriteRule ^index\.php$ index.php?module=Home&action=index Now, this would work fine except sometimes all the data will be POSTed so I need a RewriteCond so the rule will only fire