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
2answers
51 views

Does Google index page URLs with languages parameters as a different page?

If I implement multilingual access to the resource through the parameter: 1) https://example.com/en/article-1 2) https://example.com/article-1?l=en So, does Google index both of them as a single ...
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&...
1
vote
1answer
31 views

URL Character Counting - Where to start counting?

I'm rewriting URLs for a website, I know it could affect SEO, but I've no choice but to rewrite them, and 301 redirect the old ones to their new URLs. I want to try to keep the new URLs short and to ...
2
votes
1answer
68 views

How to configure .htaccess to rewrite all requests into a folder, except a list of exceptions

I have an established website with some legacy folders I would like to keep. https://example.com/.well-known/ https://example.com/Music/ https://example.com/Rutabagas/ I've also installed ...
4
votes
1answer
54 views

How would you implement redirects for domain canonicalization, no-www, and HTTPS for IIS 7.5

For the moment I'm stuck with an IIS-server, unfortunately not my best subject (I'm much better w. Apache). We have a site on a Win 2008 R2 Server with IIS 7.5. It's an old site and we are working on ...
2
votes
1answer
33 views

How to rewrite using .htacess when there is a ? (question mark) at the beginning of the URL?

Many JS functions on my site are sending Ajax request to /?something=3213214 but I need to redirect them to /something=3213214 When I do: RewriteRule ^test/(.*) /$1 [R] It does redirect /test/...
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
51 views

Using IIS URL Rewrite module instead of Global.asax for complex redirect rules

We have a legacy ASP.NET website in which complex redirect rules are coded in Global.asax. Actually this logic processes requests with several optional or variable parts like {http|https}://[www.]...
0
votes
0answers
23 views

How to redirect an URL properly using PHP taking SEO into consideration?

Explanation of the problem I want to redirect each page from a non-friendly url to a friendlier one. I've already achieved that using mod_rewrite in an .htaccess file that does send every visitor ...
2
votes
1answer
38 views

Does a new permanent rewrite rule supersede old permanent rewrite rule?

Ages ago we included a redirect in web.config to ensure that pages would rewrite to http://www.example.com/ if the user input, say, www.example.comor variants of it. Recently we changed the site so ...
2
votes
3answers
4k views

How to add a single file exception to a rewrite rule that adds a slash to wp-admin by redirecting to HTTPS?

I need to change this so that one file in wp-admin is not forced through https: # add a trailing slash to /wp-admin RewriteCond %{REQUEST_URI} ^.*/wp-admin$ RewriteRule ^(.+)$ https://%{SERVER_NAME}/$...
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
68 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
30 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
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 ...
2
votes
1answer
41 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=...
2
votes
0answers
84 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
25 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 ...
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
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
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 [...
1
vote
2answers
766 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 ...
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
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
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/...
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
73 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://...
4
votes
3answers
2k views

Best SEO practices for mobile URLs: 301, rel=canonical, or something else?

I am developing a site with a mobile version and am trying to figure the appropriate way to manage the URLs for search engines. So far I've considered: Having a separate mobile site (m.example.com) ...
2
votes
1answer
248 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
33 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
4answers
15k views

Remove folder name from rewritten URLs

Consider this URL: http://example.com/gallery/20141111-some-title In this URL I want to hide gallery/: http://example.com/20141111-some-title How can I achieve this using mod_rewrite? I used ...
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:/...
1
vote
2answers
2k views

How do I force a www subdomain on both HTTPS and HTTP?

For whatever reason I can’t seem to get this right. I’ve looked at many examples on here and on the Apache website. I’m trying to force www.example.com instead of example.com on both HTTP and HTTPS, ...
1
vote
1answer
2k 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....
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 ...
1
vote
0answers
85 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 ...
0
votes
1answer
164 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 ...
2
votes
4answers
25k views

How do I do URL re-writes on Plesk?

I am very new to URL re-writing and I am using Plesk which is window-based web server, hence I can't use Apache's mod_Rewrite. Can anyone tell me what is the proper procedure for this?
2
votes
1answer
351 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....
0
votes
1answer
118 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/...
3
votes
1answer
531 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 ...
6
votes
2answers
19k views

URL Rewrite http to https EXCEPT files in a specific subfolder

I am trying to force all traffic on my web site to use HTTPS, using the URL Rewrite 2.0 module added to IIS 7.5. I got that working and now have a need to exclude a couple of pages from using SSL. So ...
3
votes
2answers
358 views

How can I rewrite an old URL using variables to a static html page?

I am trying to redirect old URLS to the new URLS, the old site used variables in the URL but the new site uses SEO friendly URLs. When I try to redirect the old URL, it is not redirecting correctly ...
4
votes
1answer
174 views

Why is www. working but no-www is not?

Right now my site runs on http://www.example.com but I need to run that without www also i.e example.com Can some body tell me here that how can i do that?
1
vote
0answers
128 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 ...
6
votes
7answers
12k views

How do you remove invalid characters when creating a friendly url (ie how do you create a slug)?

Say I have this webpage: http://ww.xyz.com/Product.aspx?CategoryId=1 If the name of CategoryId=1 is "Dogs" I would like to convert the URL into something like this: http://ww.xyz.com/Products/Dogs ...
2
votes
1answer
225 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 ...