Questions tagged [mod-rewrite]

The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Using .htaccess for temporary redirects while updating live site

Apparently there are nocache rules that can be added to .htaccess for temporary redirects, such as while updating a live WP site. In researching a difficulty with my browser getting "stuck" ...
1
vote
1answer
49 views

.htaccess rules for blocking bots with an extra condition

I have a WP multisite installed. I am integrated with Ezoic and Cloudflare. I had implemented firewall rules. However, I have an issue blocking bots that have X-Middleton in the User-Agent, because my ...
0
votes
0answers
20 views

Mysterious site access error

I'm a bit stumped because of a weird access problem of a WordPress site. The site is on the main corporate domain, and recently, the client has had office365/active directory installed for his network....
2
votes
2answers
27 views

.htaccess redirects disappeared after re-saving permalinks

I want my WordPress website to load with https + non-www and without trailing slashes. I put the following code in .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On # Remove trailing ...
1
vote
1answer
31 views

How to remove wordpress directory slash

I have installed a website in my domain directory like example.com/website. The main issue or problem is that it redirects me to example.com/website/. I never want redirection and I just want that my ...
1
vote
0answers
18 views

Wrong Redirect/Rewrite Rules?

i'm a total newbie to rewrite and redirect rules and i have some strange problems on my multisite. when i try to open www.my-website.com/blog or www.my-website.com/xmas for example, in safari browser ...
1
vote
0answers
14 views

Problem with change url for all subpages (.htaccess)

Im looking for someone who will knowing the main code I have subpages with ugly names http://grimlord.eu/index_pl.php?src=home How cut it for this url grimlord.eu/start Pls tell me how? RewriteCond %{...
2
votes
1answer
39 views

Protect Upload Folder Files With Ampersand Problem

Wondering if anyone can help with this problem. I have been able to get file protection working in WordPress with the method below: .htaccess RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^wp-...
1
vote
0answers
17 views

Displaying Post with Custom URL with RewriteRule or add_rewrite_rule

I'm having what I believe is a common issue: I want to display a post with a slug with a custom URL, in my case, this is the format /resources/{state}/{city}/{location}/ which would match a post slug ...
1
vote
1answer
19 views

Site in subfolder - all pages work except home

Our WordPress site is in a subfolder /subwp/, and all pages except the home page work. This is the root folder: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /subwp/ RewriteRule ^index\....
1
vote
1answer
32 views

blocking access to all post/tag URIs via htaccess

I want to block all access to the post/tag/example-here pages on a WordPress site, but the following does not work. The .htaccess access file is being parsed. It is at the root of the site (ie the ...
1
vote
1answer
62 views

WordPress Permalinks still not working despite all necessary settings

I apologize for the seemingly duplicate issue posting but I can't seem to find someone who has come across my specific issue and resolved it. This post got close but I did everything they did. here's ...
1
vote
1answer
40 views

Why is the domain name missing from the logout redirect?

My development computer recently had to be rebuilt so I am now trying to migrate a WordPress site from the hosting company to my development PC. So far I have done this: Installed XAMPP. Download ...
4
votes
2answers
63 views

How to change default page slug?

I have a CPT called jobs and a page named Job Apply. I am trying to achieve something like below url: http://example.com/job-slug/apply Where, job-slug can be any job. i.e Programmer, Developer etc.. ...
1
vote
0answers
24 views

Rewrite URLs - Custom Post Type - Post Slug, Taxonamy Slug

Am using a third-party plugin for listing schools. Custom Post Type = school Custom Post Taxonomy 1 = school_type (eg. values = Primary, Intermediate) Custom Post Taxonomy 2 = school_location (eg. ...
1
vote
2answers
185 views

URL Rewriting for PHP script on an image URL

I built an image randomizer so that when I open a .php file in a URL that it displays the image with readfile($randomImage);. This works locally but when I upload it to the server it gets blocked by ...
0
votes
0answers
18 views

Custom rewrite rule for use wordpress as backend

I'm using Wordpress as backend for my site, my installation is at https://wp.domain.com. I would like to create a custom rewrite rule for deny the search engine access my domain, why my SEO not is ...
1
vote
1answer
78 views

Wordpress rewrite rules don't need ^?

For example this code class My_Sitemap { public static function install() { add_filter('rewrite_rules_array', array(__CLASS__, 'rewriteRules'), 1, 1); global $wp_rewrite; ...
0
votes
1answer
49 views

Understanding Redirects

I have a WordPress website that is working well. The website is shared hosted on a popular hosting site. It was migrated/transferred from a different hosting site to the current one (this point is ...
0
votes
0answers
8 views

How to make mydomain.com/[post_typeA]/[post_nameB]/[post_nameA] not 404: custom post types rewrite rules. ([PostTypeA]/[ParentPage]/[ChildPage])

I scoured this forum and a lot of others but I have not found the answer and starting to doubt whether it's even possible.. I'm trying to make a site with week and day posts, a day post is called "...
2
votes
1answer
75 views

Remove File Extension for Page Outside of WordPress

I need to add a plaintext page to my server that is outside of WordPress (it can't have any HTML on it). I created the page off of public_html, but I have to add a .html extension to get the page to ...
3
votes
1answer
580 views

Without index.php in permalinks I get 404 across site

As the title says, when I change my permalinks in the admin, all my pages return a 404 (except homepage). I have to inlclude index.php as the start of all the different paths. The paths all work fine, ...
0
votes
1answer
78 views

404 not working, going to homepage; how to fix?

Whenever I call a non-existent page, say http://www.example.com/foobar/, it should invoke the 404.php theme template file. In my case, however, the site redirects to the homepage, / I'm not sure ...
1
vote
0answers
93 views

Change pagination url format

I have a URL like this: example.com/blog/page/5 I want to change it to: example.com/blog/page-5 I tried using a RewriteRule like this: RewriteRule ^blog/page-([0-9]+) /blog/page/$1 but this ...
1
vote
0answers
89 views

How to remove specific category from URL in Wordpress

My custom structure permalink is set as shown below and category base is set to . /%category%/%postname%/ My current URL structure is this: http://example.com/aaa/slug http://example.com/bbb/slug ...
2
votes
0answers
209 views

Why does multisite bypass WordPress for wp-content, wp-admin, wp-includes and .php files?

When you set up WordPress to use multisite, you're directed to modify your .htaccess file to use one of the following, which are outlined in the admin and the WordPress documentation: Subfolder ... ...
0
votes
0answers
30 views

How to stop rewrite from redirecting

Following is my URL rewrite code for a single page of my wordpress site. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...
3
votes
1answer
1k views

.htaccess rewrite rule for removing .php extension with exception of wp login and wp-admin

This is my current .htaccess: # Remove filename extension <IfModule mod_rewrite.c> # This will remove the .php extension if it is not a directory, the file does not exist and it's not a ...
1
vote
1answer
2k views

Rewrite rule to load images from production does nothing

I'm trying to adapt the rewrite rule given in Develop Locally, Use Images from Production to do the very same thing on my local dev site (which runs on XAMPP). This is how the development site's ....
0
votes
0answers
105 views

Block bad bots with mod_rewrite and save in blacklist

I have a WP site in a shared hosting server (LAMP stack). Receiving a lot of 404 errors (security plugin log file) for bots looking for non-existing wp-login url (Ex. example.com/en/wp-login.php). ...
1
vote
0answers
29 views

Read GET parameters in APACHE Mod Rewrite rules for WordPress categories in Posts

I'm a self-taught programmer with a very little experience in WordPress programming. I'm using a post permalink structure in this way: https://domain.com/parent-category/child-category/post-title-...
0
votes
1answer
276 views

Redirect Wordpress site to a landing (construction) page using htaccess, with access to /wp-admin and /invoice

I have tried everything I know and I can't seem to come up with a solution. I am trying to redirect my website to a landing page (which I have put into a folder with a css file, changing the index....
0
votes
0answers
47 views

Changing permalink stops me from creating webpages

I've just created a new WordPress site. When changing the permalink structure I cannot create or edit pages. I do have mod_rewrite enabled but alas still get errors. How can I fix this? I've had this ...
0
votes
0answers
69 views

htaccess redirect to path

I'm trying to get my site to redirect to a certain folder depending on a condition. This condition cannot be done within WP, so... Anyway.. I've done conditions before, but I keep hitting a wall ...
1
vote
1answer
53 views

Redirections and rewrites to subdomain

I am currently working on a new WordPress website, to partially replace a non-WP website that includes a webshop. Now, the plan is to migrate the webshop and all matching pages (shopping card, order ...
1
vote
1answer
613 views

htaccess, site and staging in subdirectories

I have the following task and as it is a little different from most setups, I couldn't find any hints that solved my problem. WordPress for the live site was installed into a subfolder /wp1, the ....
0
votes
0answers
382 views

Can I add a rewrite rule in htaccess to remove the multisite subdirectory from the URL?

I am working on a Multisite that was installed and activated on an old version of WordPress. The WP files were placed in a subdirectory named /wp/ and now a request has been made for the subdirectory ...
1
vote
2answers
639 views

How to redirect specific URL to Subdomain

I am trying to write a .htaccess rule to redirect the URL to a subdomain. Example: example.com/pagecategory/page-single → pagecategory.example.com/page-single I've added wildcard subdomain on my ...
1
vote
1answer
99 views

Custom rewrite not working

I'm trying to rewrite URLs on my wordpress site to match Googles "seo friendly" policy. I want to rewrite URL's for 3 types of queries generated from search plugin: a) Location example.com/used-...
0
votes
0answers
38 views

How can I put WordPress in a directory but keep just the home page at the domain root?

I look after the site(s) for a large annual event. Each year we want to archive last year's website and the last few years I've done that by making a copy of WordPress in the appropriate directory. ...
0
votes
1answer
106 views

Pretty URL via Rewrite

I'm building a dynamically populated profile page for my site users. This currently uses the following URL structure: https://example.com/members-list-profile/?&uid=XX I'd like to improve the ...
1
vote
1answer
100 views

SEO Friendly URL on dynamic product page produced via shortcode

I have created a product page in wordpress, /product. This currently takes the id of a product /product/?id=123 The page has a shortcode that then fetches and displays the relevent data e.g. [...
0
votes
0answers
64 views

URL Rewrite 404

I've got the following ReWrite rule: add_rewrite_rule("details\/([a-zA-Z0-9_]+)\/.*", "detail/?id=$matches[1]", "top"); Which seems to be adding in the following to my .htaccess, which now looks ...
1
vote
1answer
41 views

.htaccess rule to redirect old URLs to new structure [closed]

The old URLs were in the form: https://www.example.com/collection/item/item-name-123 The new URLs are in the form: https://www.example.com/collection/item/123 I'm attempting to redirect any hits ...
0
votes
1answer
114 views

Permalink sub-routing catch-all

I have a client side web application which is loaded for two post types: /tutorial and /dashboard. WordPress routing works fine for the individual posts: /tutorial/tutorial-1 and /dashboard/dashboard-...
1
vote
1answer
52 views

How to write .htaccess so that https is on for subpages only but not the home page

The root of my domain successfully redirects to a subdirectory, meaning example.com redirects to example.com/abc. example.com has no WordPress install. example.com/abc has its own WordPress install. ...
1
vote
0answers
681 views

Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page

I'm migrating a site between hosts and am having issues with what should be(!) a fairly simple rewrite of a "pretty" URL to display posts filtered by category. domain.xyz/category/cat_name/ => ...
3
votes
5answers
994 views

htaccess rewrite for author query string when WP is in subfolder

I have successfully forbidden access to any kind of author pages whether trough /author/username/ or the ?author={#id} query string. I did this with this added to the beginning of my htaccess file: &...
1
vote
1answer
8k views

How To Fix A Redirect Chain

I hope someone might be able to help with this. My site crawl is showing that I have a redirect chain on my home page. Basically it shows I am going from : http: > https: > https://www. I need ...
0
votes
1answer
260 views

.htaccess rewriterule being ignored - tyring to remove dates from WP posts

Should be a fairly simple procedure. I've done a fair share of internet searching and can't get the htaccess rewrite to work in /public_html Using a VPS Apache server, any idea's why? Thank you in ...