All Questions

Filter by
Sorted by
Tagged with
2
votes
1answer
23 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
27 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
32 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
67 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
39 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
vote
1answer
112 views

.htaccess rewrite stops working for javascript files after moving server

We recently moved an old PHP Project from a server using httpd to our regular prod. servers running apache2. In this project we have some reroute rules that map requests either to our index.php file ...
1
vote
0answers
50 views

Password protect a website only if it is the dev site [closed]

I am trying to password protect a website only if it is the dev site using .htaccess and .htpasswd I am using Apache 2.4.29 on Ubuntu 18.04 Here is what I have in the .htaccess file <If "%{...
2
votes
1answer
304 views

Removing PHP Extension in sub directory

I use the following rewrite rule to remove the .php extension from my page urls: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] This works great in the root directory of my ...
2
votes
1answer
41 views

Order of RewriteRules is affecting the result

This is my current .htaccess: RewriteEngine On RewriteRule ^([\w-]+)/([a-z0-9]+)/([a-z-0-9]+)$ index.php?p=$1&bay=$2&map=$3 [L] RewriteRule ^test/([\w-]+)/(\d+)$ index.php?page=$1&tab=$2 [...
2
votes
1answer
48 views

Apache rewrite to www. unless it is a dev domain

Here is my current rewrite code in my htaccess file: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://www.%1%{...
2
votes
1answer
115 views

How to rewrite specific pages using mod rewrite?

Assuming that my website homepage is https://example.com/test-website/. What I want to do is to add a query string at the end of the homepage URL and on all pages that start with https://example.com/...
1
vote
1answer
89 views

FrontController dosen´t work

i have a example FrontController, its really simple. index.php: if (isset($_GET['page'])) { $requested_page = $_GET['page']; } else { $requested_page = 'home'; } switch($requested_page) { ...
2
votes
1answer
38 views

Can I use a rewrite rule to send all requests to a single file?

Can I make a single regular expression for all my RewriteRules? I'm rewriting everything to a single file and this this acts like a front-controller. My example: RewriteRule ^de/kontakt/anfahrt$ ...
1
vote
1answer
35 views

How is the mapping done from …/script.php?one,1 to …/script/one/2?

There is a PHP script which evaluates one or two parameters via QUERY_STRING. This script should process the parameters via QUERY_PATH. The PHP file type should be omitted. Request of the form https:/...
2
votes
1answer
58 views

Rewrite rule not taking effect

I need to place a rewrite rule in my .htaccess file so that requests for http://example.com/jbossas/jboss-configuration are redirected to: http://example.com/jboss-server/jboss-configuration So I ...
3
votes
1answer
395 views

Multiple rules to rewrite the url

Why both rules don't work together and how can i fix it? Only the first one works... I think that there's a conflict between the two rules, but i did not found a solution yet ?p= is the querystring i ...
1
vote
1answer
808 views

RewriteCond %{HTTPS} !=on is not working even though RewriteCond %{SERVER_PORT} !^443$ works

I have a requirement to check for non HTTPS URLs in htaccess. My understanding is that RewriteCond %{HTTPS} !=on will match all URLs that are not HTTPS. But upon testing, I find RewriteCond %{HTTPS} !...
1
vote
0answers
37 views

Error in SEO Friendly URL [closed]

I have below url structure http://example.com/blog.php?blogURL=user-already-has-more-than-max_user_connections-active-connections and I want to below http://example.com/blog/user-already-has-more-...
2
votes
1answer
70 views

Apache rewrite existing rewritten url [closed]

I know how to create rewrite rules in Apache but what I don't know is how to rewrite a previously rewritten url. This is an old URL /boats-for-sale/fairline-squadron-55/1280 and I need to redirect ...
3
votes
1answer
157 views

HTTPS redirect, exclude script parameters from URL

My goals: 1. http://example.com/page/index.php -> https://example.com/page/ 2. http://example.com/page/ -> https://example.com/page/ 3. http://www.example.com/page/ -> https://example.com/...
4
votes
2answers
4k views

How to force ssl and www for a subdomain as an independent domain?

I have own the example.tld . I want to force SSL and https for root-domain and all of its subdomains. I have used below code in .htaccess file of root-domain: RewriteEngine On RewriteCond %{HTTPS} ...
2
votes
1answer
40 views

Redirecting from one page to another page on my website causes 404 error after using .htaccess file

Currently I'm working on a PHP blog. Where I have used an .htaccess file to get a clean URL, here is the code: RewriteEngine On RewriteCond %{HTTPS} !=off RewriteCond %{HTTP_HOST} ^example\.com$ ...
4
votes
1answer
541 views

How to use rewrite rule to create exception rule for https redirection for directory ./well-known

Here is my situation: Server A: support.example.com -> port 80 is forwarded to this server Server B: hr.example.com Both are running apache2. For server B I want to use Let's encrypt. I want to ...
6
votes
1answer
969 views

Rewrite wildcard subdomains in .htaccess to corresponding folders on the main domain while preserving the subdomain

I'm trying to rewrite a subdomain to a folder/file like this: name.example.com -> example.com/profile/name foo.example.com -> example.com/profile/foo xyzzy.example.com -> example.com/profile/xyzzy ...
0
votes
1answer
498 views

How to redirect port 80 on server A to 443 server B

I'm wondering how can use my server A to redirect different URL's to the respective server. Here is my setup: Server A: apache 2.4 on ubuntu 16 Server B: apache 2.4 on windows 2012 Port 80 is ...
2
votes
0answers
483 views

How to use .htaccess rewrite rules to remove .php and folders from URLs?

I'm trying to simplify the URLs using rewrite condtions and rules on my local WAMP website. For example I would like to have /ProjetSyntheseFAC/mammiferes instead of /ProjetSyntheseFAC/pages/animaux/...
2
votes
2answers
97 views

.htaccess RewriteRule leading to unexpected page

I'm trying to do a simple invisible redirection with .htaccess which almost work. I'd like my main domain name example.com to access the content of the folder example.com/V8/ but keeping only the ...
2
votes
2answers
8k views

How to remove subdirectory folders from the url using htaccess

I am trying to remove the sub-folders from my site URL. Below is the structure of my folders. I am not sure where to place my .htaccess file and what to have written in it: mysiteroot ...
0
votes
2answers
1k views

Apache .htaccess: Is it possible to write an if condition for a cookie value check?

I want to write an if condition in an .htaccess file to check whether a cookie value is set. Example code: <If "%{HTTP_COOKIE} == 'cookiename and value'"> ... </If>
1
vote
1answer
91 views

Use .htaccess to make pretty URLs that expand abbreviation codes

Yes, I know, there are tons of questions like this, but I can't find one which solves my problem so at cost of receiving downvotes I'm going to ask this again. Even a duplicate link may help me. This ...
2
votes
1answer
2k views

(nginx rewrite) add word on dynamic URL ending | word is repeated multiple in URL

I'm really confused by the Nginx rewrite rules. I have searched and found a lot of threads for rewrite rules but I don't get the required result... I have this form of a link: http://example.com/...
5
votes
1answer
3k views

rewrite url - remove trailing / if any and add .php

I have a simple question, yet I've found no posts that answer my question. I need an htaccess file that rewrites the urls so that it removes the ending / if any, and adds .php no matter what the ...
1
vote
0answers
141 views

Create unique IDs between URL with nginx [closed]

I searched and tried nearly two weeks but don't get any useful result, so I'm trying my luck here before I get crazy: Every existing domain should get an unique ID right after the domain. The ID ...
1
vote
1answer
691 views

Rewrite URL with multiple queries

This article describes how to direct incoming traffic coming from "fake" URLs of this type: http://www.example.com/seo-sample/article-install-apache-on-linux.php to a PHP file that "really" uses ...
6
votes
2answers
6k views

Have Apache show 404 at missing page URL instead of redirecting to error page URL

Assuming non-existent-page.html does not exist, and the user is trying to access that page and triggered a 404 error. Can i show the requested page URL: http://www.example.com/non-existent-page.html ...
3
votes
1answer
76 views

Why does apache redirect to www without RewriteRule

So I have a webserver running on Apache, with a few virtual hosts. I want to default to https and hence I have a rewrite rule. <VirtualHost *:80> ServerName example.com ...
3
votes
3answers
1k views

Redirect $.html to $/ mod_rewrite rule clash

I have already remapped URL's from for example /sub/test/ to test.html but I also want to redirect /sub/test.html to /sub/test/ but here seems to be a clash between the rules. .htaccess files is in ...
3
votes
2answers
78 views

Is a real http to htttps rewrite possible or is this always going to be a redirect?

I noticed that there are some articles on the Internet that talk about using the apache mod_rewrite module to rewrite a client to server http connection to https. But rewrite does all the changes ...
2
votes
1answer
165 views

Forcing the removal of query string on a rewrite rule

I find I'm the only one coming up with bizarre behavior on my website. Now one of my extremely important links has malfunctioned. This is the RewriteRule I have that malfunctioned: RewriteRule ^m/?$ ...
2
votes
1answer
926 views

Can rewriterules work without carets or dollar signs?

Currently when I remap my friendly to non-friendly URLs on my website, I normally use lines like these in my .htaccess: RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} !^$ RewriteRule .* - [L] ...
0
votes
1answer
22 views

Is a blank really a directory when dealing with mod-rewrite?

I spent about 20 minutes wrapping my head around this, and finally came to a solution but did not know why it worked. The important lines (as it relates to this question) in the apache configuration ...
3
votes
1answer
583 views

After rewriting URL page not found

I want to rewrite my current URL that is http://localhost/sitename/landing-page/?from=Algeria&to=Afghanistan&submit=Submit to http://localhost/sitename/removals-from-Algeria-to-Afghanistan ...
1
vote
1answer
47 views

After mod_rewrite the internal URLs are duplicated many times when crawling

I'm sure it is my mistake in mod_rewrite rules, but I can't seem to figure it out. I've set up the rules for my new site and all works perfect, unless - I try to create a sitemap. The URLs get ...
3
votes
1answer
105 views

A more specific question about a tricky redirect case

me again. :) I will try to keep this more to the point. Synopsis: I am trying to redirect URLs like this: www.desktopscenes.com/Scenes from Yellowstone (2003)/slides/Morning Glory Pool.html to this:...
4
votes
1answer
51 views

Need expert help with tricky redirect problem [duplicate]

I actually posted about this years ago, never got anywhere. Did more research, did testing, got something I thought worked and mostly did, but it seems to get bogged down in infinite loops under ...
1
vote
2answers
5k views

How to change my id and name in php url

How would I change the URL from from: example.com/games.php?id=27 to: website.com/games/271/game-name-here So far I have this in .htaccess: RewriteEngine on RewriteRule ^games/([0-9]+)/?$ games....
1
vote
2answers
545 views

Apache 2.2 Not Identifying Safari with HTTP_USER_AGENT

I have a web server that has to meet PCI compliance requirements. Their latest round of policy changes have removed support for Safari, after having removed support for Windows XP based IE clients. ...
1
vote
1answer
337 views

Do we have any redirect solution for all of subURL?

Suppose I redirect exmpale0.com to example1.com , example1.com is newer. Already , I promoted my exmpale0.com into social networks , Suppose I had: http://example0.com/blahblah Now I have ‍http://...
0
votes
1answer
18 views

stopping accessibility of internal script files via mod_rewrite

Turns out after researching, one site found duplicate content on my website. The reason is because the unfriendly php file that friendly URLs link to was apparently discovered by a robot and then got ...
0
votes
0answers
869 views

Using mod_rewrite to set cookie and modify domain name

I have two editions of a website. The mobile and desktop version. All desktop sections of the website have normal urls and mobile sections have subdomain urls suffixed with the word mobile. Example: ...