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
6 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
31 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 ...
0
votes
0answers
6 views

How the best way to get and publish single post from network in Wordpress Multisite and create permalink for it like “blog/%site_id%/%postname%”

My idea is collect post from subsites to main site in Network WP MS and open it there. I have found nice class https://github.com/miguelpeixe/WP_Query_Multisite for Multisite Querying. Now i want to ...
0
votes
0answers
15 views

how to create mod_rewrite permalink from function.php

I have this link: https://www.domain.com/directory/education/slug1/slug2?pg=4 https://www.domain.com/directory/education/slug1/slug2/pg/4 slug1 = dymanic slug2 = dynamic another is same except the ...
2
votes
1answer
111 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
40 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
29 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
44 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 ...
1
vote
0answers
119 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
25 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
333 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
759 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
60 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
28 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
85 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
46 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
24 views

Rewriting the wp-content but not entirely

This could be tricky question. I need to rewrite the wp-content folder, but not entirely, this means, being able to use an alt path, but still maintaining the full route of wp-content by default For ...
0
votes
0answers
53 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
43 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
285 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
205 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
165 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
74 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
37 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
85 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
86 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
57 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
40 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
58 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
38 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
483 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/ => ...
2
votes
3answers
642 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
6k 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
145 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 ...
1
vote
2answers
68 views

mod_rewrite empties QUERY_STRING if starting with number [closed]

I have a simple database query script alongside with my WordPress installation, to which I pass a parameter using the following URL: http://example.com/db/?p=foo. My database script reads the ...
1
vote
0answers
253 views

How to rewrite wordpress urls with index.php in them

I want to make custom WordPress URLs like this : http://example.com/index.php?productID=123 and for categories http://example.com/index.php?categoryID=123 and the reason is we have a website written ...
3
votes
2answers
661 views

Remove year and month in URL using .htaccess

For example, to redirect old URLs of the form: /2016/10/mukunda-murari-kannada-songs-download.html To /mukunda-murari-kannada-songs-download.html I have already changed the permalink structure in ...
0
votes
0answers
564 views

using htaccess to check for cookie on permalink then conditionall rewrite with query parameter

On a wordpress site(also looking for multisite solution), looking for .htaccess to check for cookie being set, then if cookie is found add a parameter to the permalink. It works for top level, but any ...
4
votes
1answer
1k views

Wordpress on a subdirectory of Laravel - Wordpress pretty permalinks inner page shows laravel

I read lots of discussions about this and found no solution. I have a Laravel web app and added a Wordpress site in a subdirectory. This is what my .htaccess looks like within the public folder: <...
1
vote
0answers
99 views

Rewrite Rules and Login Issue

I have rewritten the rules in the .htaccess file of my root domain and now it shows exactly the same content as my subdirectory. Important: it is not been redirected to it. 2 seperate sites with ...
0
votes
0answers
44 views

htaccess question and plugins.php

Does anyone know what this is doing: RewriteRule ^admin/(.*)?$ admin/index.php?a=$1 [QSA,NC,L] I'm having a problem accessing /wp-admin/plugins.php and I'm not sure if it's caused by the RewriteRule ...
1
vote
0answers
30 views

Custom Rewrite rule to captured post (rewrite rule to rewrite rule)

I couldn't come up with a better question-title; Sorry! The example will clarify things quickly. My rule: add_rewrite_rule("^podcast/(.*)/time/([\d|\:]+)", "/podcast/$1/?time=$2", "top"); In words: ...
1
vote
1answer
163 views

Taxonomy Pagination Rewrite

I have a custom post type named "testimonials" with a slug of reviews. I also have a taxonomy named "testimonial-department" with a slug of reviews. The goal being I will have pretty permalinks such ...
1
vote
1answer
458 views

Cache Busting using htaccess Rewrite rule?

I am trying to follow this tutorial that says i can make a server to send a file like style.css if the requested file is style.15458888.css with a rewrite rule to be put inside the htaccess file. ...
1
vote
1answer
980 views

How to create a redirect in the .htaccess file, with 2 exceptions

So I've been trying this for a long time, but I can't seem to get it to work. Pretend my website is https://example.com, with the additional pages https://example.com/abc and https://example.com/abc-...
3
votes
1answer
2k views

Mod_rewrite delete parameter in 301 Redirect

How would I go about rewriting: http://www.example.com/?aff=number to: http://www.example.com I want to remove all instances on aff=x regardless of how many other parameters in the URL.
4
votes
1answer
4k views

Place static HTML files in path below WordPress page

I have a WordPress instance running on my domain's root. One WordPress page is located at www.example.com/product/. I placed some static HTML files in a path below that so that visitors can go to www....
0
votes
1answer
975 views

Rewrite rule and display of post

I'm trying to create a permalink for single posts that are in a particular category called 'Test'. So I've set the stub with a filter which in turn sets the permalink when the post is saved. At the ...
0
votes
1answer
905 views

Cannot get 301 redirection in htaccess to work (either Redirect or Rewrite)

I have recently changed how posts are categorized and changed the permalinks not to show the category. Consequently, I need to redirect the old URLs. I have tried many variations of the following but ...
0
votes
1answer
108 views

force www rewrite if wordpress put in a folder

My wordspress site is installed in myfolder and it auto create the code in htaccess # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /myfolder/ RewriteRule ^index\.php$ - ...