Questions tagged [url-rewriting]

A URL rewrite engine is software that modifies a web URL's appearance (URL rewriting). Rewritten URLs (sometimes known as short, fancy URLs, or search engine friendly - SEF) are used to provide shorter and more relevant-looking links to web pages. The technique adds a degree of separation between the files used to generate a web page and the URL that is presented to the world.

Filter by
Sorted by
Tagged with
1
vote
1answer
43 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
34 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
32 views

Rewrite rule to give 410 Gone for a specific URL doesn't work

I'm French. A week ago, my website was hacked with the old version (http). The hack created 404 spams and I want to ensure they have "410 Gone" status. My problem on the site is: https://www.example....
0
votes
1answer
26 views

How to change the URL of a wordpress website?

By default, my URL was set to example.com/wp/wp-admin instead of the example.com/wp-admin that I used to remember. Also my website's contents show on example.com/wp rather than example.com. How do I ...
1
vote
1answer
25 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 ...
2
votes
1answer
37 views

Do search engines crawl links with query strings?

If I were to have a url like https://example.com/books, that contained several links to urls such as: https://example.com/books?id=foo https://example.com/books?id=bar https://example.com/books?id=...
1
vote
0answers
23 views

Apache VHost rewrite rule not working as it should

I have setup an Apache server inside my domain and have been creating VirtualHost in the httpd-vhosts.conf file. Up until now this has worked without issue, I have a few DNS entries externally that ...
2
votes
0answers
37 views

Is it safe to do a htaccess rewrite for mobile traffic to amp pages?

I have a requirement to use the same URL for both desktop and mobile devices. On mobile, I want to serve amp HTML while on the desktop I want to render normal HTML. In such case is it safe (from SEO ...
1
vote
0answers
47 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
46 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
32 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
40 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%{...
1
vote
1answer
53 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
68 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
37 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$ ...
0
votes
1answer
40 views

Wordpress or Apache or Nginx matching partial URL to full URI

I have a weird issue where either Nginx or Apache (I can't tell which - but I'm 90% sure it's Apache - Nginx is reverse proxying) is matching a partial URL to a full, random URL. For example: https://...
1
vote
1answer
180 views

Redirect to remove everything after the second slash (first directory)

I'm trying to redirect a lot of pages on a website I own. There are a few pages indexed and I need to fix them for example: /vloerafwerking/projecttapijt/raamafwerking/ needs to go to /vloerafwerking/...
1
vote
2answers
32 views

How to preserve ALL website's URLS when transferring to a new CMS as well hosting

I am in a position where I have to figure out how to preserve all of the website's pages URLS when transferring it to a new CMS, perhaps potentially Joomla (hasn't been decided yet). New hosting is ...
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
43 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 ...
1
vote
1answer
1k views

IIS URL Rewrite: Pattern starting with forward slash never matches

I am using IIS URL Rewrite and this one has stumped me. I am redirecting a URL with specific subfolder to a new URL. e.g. https://myapp.example.com/customsite1 redirected to https://newsite1-myapp....
1
vote
0answers
59 views

Infinite redirect loop with IIS 8.5 Drupal

After configuring my website, i stuck in a infinite redirect loop. I have 6 domains, example.com is main domain. example1.com, ..., example5.com are forwarding to example.com. Doesn't matter which ...
3
votes
1answer
71 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 ...
0
votes
1answer
132 views

SEO: Is a redirect without using 301 but a PHP script, OK?

I've been reading about redirection, and how it can affect (or not if done properly) SEO. I'm changing my website's content platform from Drupal to a PHP custom made code. In my current site I have ...
1
vote
1answer
255 views

NGINX - Rewrite version number in JS file name to parameter for PHP

I had a rewrite from file.js?c=123 to file.js.php?c=123 but query params were downgrading my SEO evaluation. Actually, some proxy CDN do not cache query params. server { location ~ \startscript....
2
votes
1answer
386 views

NGINX - Rewrite .js.php file to .js

I have a dynamically created file start.js.php?c=21 and I would like to rewrite it's extension (to start.js, with query params). Is that possible? Is that a good method having such a rewrite? Is ...
0
votes
1answer
89 views

Nginx url rewrites for changed shop categories

We recently moved from Magento 1 to 2, during the move we cleaned up our category urls to be more consistent. For instance we changed: /mens/mens-accessories/mens-wallets to : /mens/accessories/...
1
vote
0answers
93 views

nginx rewrite rule not applied (using contao cms)

I am trying to make a redirect for https://mypage.com/foo to https://mypage.com/bar while still keeping https://mypage.com/foo in the browser url. I have tried several combinations of different ...
2
votes
1answer
187 views

How would you write an http to https redirect rule for web.config on IIS8 that would go directly to preferred domain with www.?

I have a site that we just setup with SSL and have a redirect rule set up in web.config. We also use the www. as the preferred domain. The problem I have is I want to skip the middle step in the ...
1
vote
1answer
42 views

Why hide .NET URL extensions and make them appear to be .html?

I'm new to the web engineering and I have done some searching for URL/Domain masking. In my company, my HOD asked one question during meeting and wants the answer in the next meeting. He asked that ...
1
vote
1answer
582 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
25 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-...
1
vote
0answers
16 views

How do I access the wp-admin interface of a site that lives inside a joomla folder, using IP address / siteground server URL?

For historical reasons, we have several sites that live inside the public_html folder of a different site (all hosted on sitegrounds). To complicate things up, the root domain has a name that is the ...
1
vote
1answer
60 views

www subdomain cannot be in subdirectory, how to organize files on server?

I have just switched hosting providers and stumbled across a limitation that bugs me. Previously I had the following mapping between domains and files on the webserver: example.com → /web/...
1
vote
1answer
59 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
109 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
2k 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
1k views

IIS HTTP/S rewrite with SSL offloading non-standard local port

I posted this in a different forum and got nothing, so I'm a bit desperate. Here is my scenario: IIS running sites on 80 and 443 - external.foo.com and https://external.foo.com On the same node, a ...
1
vote
0answers
46 views

What's the best practice URL Path with multiple occurences of the same parameter?

Case User searches on a website for "cake" and filters the results via two categories: "united states" and "germany". Researched best practices SEO relevant and as short as possible URL if possible ...
1
vote
0answers
38 views

Remove non-existent language directory from URLs under nginx

I've got URLs like this: /lang/path-to-file.ext and I want to remove the "lang" because it doesn't exist: /path-to-file.ext How do I do that on an nginx server?
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
403 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 ...
2
votes
1answer
72 views

Googlebot URLencoding longtail URLs which is causing server errors

My Google search traffic has been growing consistently for months without any hiccups. Then a few days ago, Google dropped my traffic by about 80% in one day. The traffic would then later rebound ...
4
votes
1answer
526 views

Nginx rewrite problem - displaying same page with or without .php extension after rewrite

I have implemented the following Nginx code: location / { try_files $uri $uri.php $uri/ @extensionless-php; index index.html index.htm index.php; } location ~ \.php$ { try_files $uri =...
1
vote
0answers
35 views

If I link to clean URLs based on the page title but redirect to URLS with ids as part of a site migration, is that bad for SEO?

I'm importing stuff from a Drupal site that has a couple of alias URLs: /node/123 /my-alias-node-title My new site is a very simple CMS handmade in PHP by me as a practice. In the new system, the ...
3
votes
1answer
287 views

Possible to match special characters with mod_alias and `Redirect` directive?

I’m using Apache 2.4.6 with mod_alias and have a website which is receiving traffic from a link on another website that I have no control over. The other site’s link is poorly formed and it causes ...
1
vote
0answers
230 views

Method to redirect website subfolder to new website in IIS

We currently have a website, let's call it https://supersystem.example.com We also offer customized versions of the website to clients, in the past we would throw those custom files into a sub3folder ...
1
vote
1answer
47 views

.htaccess Rewrite whole dir contents to another

I am trying to rewrite the whole contents of a directory to the home url. so, if someone visits www.example.com/bnn27sh32j@d299/gold it should take them to www.example.com/gold I have tried: ...
1
vote
1answer
867 views

How to keep question mark in URL rewriting with a GET method?

I am trying to use URL rewriting to rewrite search-en.php?q=abc to pages-afficher-recherche.php?lang_abbreviation=en&q=abc and I did RewriteRule ^search-([a-zA-Z]{2})\.php\?q\=([a-zA-Z0-9_-]*...
1
vote
2answers
691 views

Forcing trailing slash at end of “fake” folders

The working codes that I've found here most put a slash in everything. I just need force trailing slash in these "fake dirs" (that are part of my rewriting scheme (only directories)) and keep ...