Questions tagged [mod-rewrite]

mod_rewrite is a URL rewriting module for the Apache web server. It is commonly used for so-called "pretty" URLs because of its ability to redirect on the server side (transparent to clients and their browsers), but also provides the power and flexibility to perform various request handling tasks beyond simple substitutions.

Filter by
Sorted by
Tagged with
2
votes
1answer
23 views

htacces rules for mobile and desktop site

I have a site that stores an index.php for desktop computers and a mobile.php for mobile devices. Both files are in the same directory (say /var/www). As default the user accesses index.php and if ...
1
vote
1answer
13 views

Htaccess Using RewriteMap with a text file

I can't use link with * Example - http://localhost/photo_gallery/public/show_c.html/color-1* The requested URL was not found on this server. The others work's color-3, wood, etc. generated map - map....
1
vote
1answer
38 views

.htaccess url rewrite remove 2 id

Is it possible to delete 2 parameters ID of the url & just show the number. Currently i have url like this: http://localhost/photo_gallery/public/product_configurator.html?prometheus_id=10082&...
2
votes
1answer
25 views

Four 301-redirects from “www.example.com” to “shop.example.com” (am I losing my Google PageRank?)

Some years ago, I started my website with the main domain www.example.com. However, the project ended up being a store under shop.example.com. I obtained hundreds of links to http://www.example.com, ...
1
vote
1answer
46 views

Url changing with htaccess

I have a web presentation with some typical url adresses. Now I need to add a rewriterule for a different languages, examples: domain/club -> do not change domain/club/path -> do not change ...
1
vote
1answer
48 views

Blocking bad bots based on useragent in apache conf

I am proposing blocking bad bots using the following code in /etc/sites-enabled/site.conf and I have a few questions. RewriteEngine On RewriteCond %{HTTP_USER_AGENT} useragent1|useragent2|useragent3 [...
1
vote
0answers
28 views

Modify rewrite rule to handle four ids rather than just one

I have rewrite rule which gives id from link to script and it works perfectly: RewriteRule ^index/viewproduct/id/(\d+)$ produkty/index.php?id=$1 [L] I need one more RewriteRule to handle URLS like: ...
1
vote
1answer
32 views

.htaccess Rewrite Wordpress Subdirectory without breaking other subdirectories

So I have WordPress installed in /wp/ but I want all WordPress URLs to be rewritten to appear in the root directory. I currently have this working (see below) but I want to change my .htaccess so it ...
2
votes
1answer
117 views

Why does RewriteRule for “^//(.*)” (begins with double slash) not redirect to a single slash?

Have this rewrite rule in vHost context. But it does not rewrite requests that begin with //.* (double slash). Just serves them up from /.* (single slash) instead of responding with a redirect to /.* ...
2
votes
1answer
87 views

301 redirect with regex: how to match any file at top domain level (not in a subdirectory)?

I need to redirect URLs of all .dmg files at domain's top level to specific folder. By way of example: http://example.com/file.dmg to http://example.com/downloads/file.dmg I can't hard code the domain ...
2
votes
1answer
42 views

Apache mod_rewrite in .htaccess

This should be a simple question. Checked Google but it listed nothing helpful. I use WP on one of my sites and it already generates a mod_rewrite section with: <IfModule mod_rewrite.c> ...
1
vote
1answer
52 views

Internal Server Error caused by rewriting [closed]

Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html [NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{...
3
votes
1answer
157 views

htaccess redirect root domain to subdomain with exceptions

i m using wordpress and want to redirect my root domain to a new subdomain and ignore urls that contains a certain string http://www.example.com/post.html To http://subdomain.example.com/post.html ...
1
vote
2answers
49 views

How to redirect some URLs to another local port with .htaccess?

I have the .htaccess file in the root public_html directory. It contains the following: Options -Indexes Redirect / /dali RewriteEngine on RewriteRule ^api/(.*[^/])/?$ http://%{HTTP_HOST}:5000/$1 [R=...
2
votes
1answer
68 views

Apache rewrite rule for parameter value to path while replacing slashes with underscores

Apache rewrite rule for, Query String replace / value with _ Source URL: http://example.com/my/service?opath=/content/home/page&appId=myapp rewrite to below http://example.com/my/service....
2
votes
1answer
36 views

htaccess Redirect Using Regex

I have 2 redirects that work fine: Redirect 301 /namedeal/ca_domain_name.php /namedeal/cheap_domain_name.php Redirect 301 /namedeal/ws_domain_name.php /namedeal/cheap_domain_name.php I want to be ...
1
vote
1answer
137 views

.htaccess to redirect URL with specific query-string, to a different domain, maintaining the query-string

What I wish to do I have one particular URL I need to redirect using .htaccess, based on a specific value being present in the query-string. A 301 permanent redirect header being sent to browser (...
3
votes
1answer
54 views

301 redirect rewrite query string in .htaccess [duplicate]

I am trying to perform a 301 redirect in .htaccess and I need to remove the query string ?view=full. Here is what I have that is not working: RewriteRule ^/contact/?view=full$ /contact/ [R=301,L] I ...
5
votes
1answer
222 views

Redirect all URLs exactly except one URL that must be redirected to a different URL

I must to change domain from example.net to example.com. To redirect all URLs exactly (www and non-www) I use: RewriteEngine On RewriteCond %{HTTP_HOST} (w*)example\.net$ [NC] RewriteRule ^ https:/...
2
votes
1answer
40 views

How to redirect all that URLs that ends with “-2” to the same link without “-2”?

I have an comparison website based on woocommerce and I have the following problem. I have 1 product from 2 vendors: Vendor 1: https://example.com/lista/ceas-accurist-signature-7220-classic/ Vendor ...
2
votes
1answer
754 views

mod-rewrite - sending any URL with “.php/” to 404

I have a substantial number of rewrite rules in place for a variety of reasons such as: disallow indexes, set custom error pages, force non-www, https, strip trailing slash, redirect index.html or....
3
votes
1answer
32 views

.htaccess rewrite rules for nonsense URLs

I have a number of rules governing the URLs on my main website & it's a pretty nice setup. There is an unintended consequence that has come up though. My latest addition cleans up a bunch of 500 ...
1
vote
1answer
49 views

How to remove slash from directory when there are more rewrite rules in the subdirectories on Apache?

I've an Angular applicaion in multiple languages. After the build process there exist a distribution for each language. These are put onto the server in locale directories: /en/index.html /fr/index....
1
vote
1answer
39 views

mod_rewrite rule for new pages that keep wildcard subdomains

I've read everything I could and can't figure this out. I need a simple page redirect that keeps the original subdomain. We have several stores on their own subdomains with identical product page ...
2
votes
1answer
68 views

How to stop cPanel messing with .htaccess and causing unexpected redirect

So I have many domains on one cPanel account, say filmstore.net, bookstore.com and sandwiches.org (the main domain). So I want to redirect anything.sandwiches.org to sandwiches.org, so I have the ...
0
votes
0answers
80 views

Mod_rewrite rule for Magento2 to access sku with # in

I have an issue similar to this question Redirect URLs with a # in .htaccess I'm trying to access Magento 2 api at /rest/all/V1/products/sku. This works for majority of products but some have a # ...
2
votes
1answer
192 views

How To Create An Exception, or or exclude certain files from a php-file-extension Snippet in .htaccess? this example failed

This is a .php file extension removal snippet, for displaying links online. RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L] This is where I make an exception to ...
1
vote
1answer
54 views

Serve all pages over https not just homepage

I want to serve all of my website pages over https, but currently my htaccess only serves the homepage over https. This is the code I have in my htaccess file: <IfModule mod_rewrite.c> ...
2
votes
2answers
152 views

How can I create a dual URL system?

I'm looking for a simple trick Let's say I have a Wordpress installation and image resources in this URL http://example.com/wp-content/images/example.jpg I would like to have the possibility of ...
2
votes
1answer
52 views

.htaccess - RewriteRule for 404 and query

I am very new to this stuff. I have a website with these RewriteCond/RewriteRule directives. Options All -Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}...
2
votes
1answer
55 views

htaccess rewriterule not working for old urls for site rebuild

I am struggling to get the rewrite rules working in .htaccess for search links on a property rental website I am working on. The old links are like this: example.com/index.php?proptype=Villa&...
2
votes
1answer
2k views

Use .htaccess to remove a directory and .php extension from the URL

I am running a Wordpress website, but I have some folders not related to the wordpress CMS, but in the same directory where all Wordpress folders are. The .htaccess in root WP folder has its standard ...
2
votes
1answer
121 views

Why do my analytics report that index.php appears in URLs despite friendly URL rewrite rules?

On a website i use mod_rewrite and PHP to create clean URL's. My .htaccess (summary) will look like that shown below: RewriteEngine On #oude pagina's RewriteRule ^nl/links/(.*)/index.php$ /...
2
votes
1answer
75 views

.htaccess, redirect all to bye.php, even with more slashes, with exception

I need, in .htaccess, redirect all behind domain, but even with more slashes and with slash or no slash at the end, but with one exception. For example example.com/all/sites/should/redirect/to/one/...
2
votes
0answers
42 views

After rewriting RoundCube URLs, CSS, JS, and image resource links are broken

What I'd like to do is that I want to make nice URLs for my roundcube pages with .htaccess. For example: RewriteRule ^latest/$ index.php?_action=news&type=latest [NC,L] If I go to this ...
1
vote
2answers
26 views

Why doesn't my .htaccess file redirect my old WordPress permalink structure?

About 9 months ago i changed my permalink structure in WordPress from the domain.com/year/month/article-name format to the domain.com/article-name one. I hired someone to do the rewrite rules for ...
2
votes
3answers
358 views

Using htaccess to force HTTPS doesn't work

NEW EDIT 28/oct/19 → I edited the .htaccess file as you said AddHandler x-mapp-php5.5 .php # HTTP to HTTPS redirect RewriteCond %{SERVER_PORT} 80 RewriteRule (.*) https://www.bebechan.net/$1 [R=301,...
2
votes
1answer
176 views

Forcing all requests to HTTPS vs not forcing all requests

I'm not new to cleaning up mixed content errors after switching from http to https and I'm not new to working with the htaccess file but I am new to actually implementing the rules for http to https ...
4
votes
1answer
66 views

Problem opening files with encoded filenames

I have a website where users can upload files, if they upload a file with a special character in the filename, the filename will be encoded (for example: iordănescu.pdf will become iord%C4%83nescu.pdf)...
2
votes
1answer
37 views

Deny Multiple Spammy Domains via htaccess

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} ^http(s)?://([^.]+\.)*tumblr\.com [NC,OR] RewriteCond %{HTTP_REFERER} ^http(s)?://([^.]+\.)*nometoqueslashelveticas\.com [NC,...
3
votes
1answer
103 views

htaccess conflicts

The issue that I'm currently forced to handle is related to a folder structure URL being redirected to the same folder structure URL but with a different string. So page-a used to exist but that ...
3
votes
1answer
84 views

What is the Cloudflare equivalent of these two .htaccess redirect rules?

I usually set up my sites to rewrite URLs in the following cases: All http traffic is redirected to https (and www), with a 301 All non-www traffic is redirected to www (and https), with a 301 In ....
1
vote
1answer
85 views

Use .htaccess to redirect to add .txt extension

I have a .txt file on my hosting and would like to redirect to it if somebody enters an specific website within their browser, e.g. example.com/webpage --> redirects to --> example.com/...
2
votes
1answer
33 views

I can't run 2 or more url rewriting rules at once

I was trying to shorten the URL more, but I was removing .php file extension from the URLs using URL rewriting too. I can't run both at the same time. Removing the extensions and trying to shorten ...
0
votes
0answers
34 views

Some links are indexable and some others are not when they are all created equal, why?

I'm trying to create a sitemap. I'm using the Screaming Frog software, but I think that this can be achieved in different ways with other software as well. My links are generated with different ...
1
vote
1answer
703 views

How can I change URL Letters from Upper to Lower case in htaccess for a specific folder?

I'm a bit stuck, so thank you for any help! In short I'm trying to convert either of the two examples (I have mod_rewrite from the first to the second already). I only want this to apply to the ...
2
votes
1answer
18 views

Apache redirection rules for wordpress sites

I want to redirect http://www.example.com/findyourname/ to http://www.newexample.com./findyourname/ http://www.example.com is a wordpress site , so when accessing http://www.example.com/findyourname/ ...
1
vote
1answer
441 views

Multiple pages under single directory redirection to a single Page

I have the following scenarios for web page redirects 1) All pages under www.oldexamplesite.com/page/product/New-Design/* and All pages under www.oldexamplesite.com/page/product/nature-of-design-...
1
vote
1answer
297 views

How to redirect all requests to HTTPS with SEO friendly URL using Apache?

First of all, I would like to leave remove www and redirect all request to HTTPS like this: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$...
0
votes
1answer
42 views

Rewrite rule messes up direct links to directories

I have a very simple rewrite rule which does the job: allows link domain.com/index.php?page=NAME to be displayed as domain.com/NAME. The problem is when I try to give direct link to the image www....

1
2 3 4 5
12