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.
212 questions
1
vote
1
answer
30
views
Are there any negative impact if access to directories were accidently denied?
Are there any negative impact if I add the following a rewrite rule on my Wordpress installation?
I am using Apache Web Server and Wordpress 6.6.2.
Note: That RewriteCond %{REQUEST_FILENAME} !-d is ...
0
votes
0
answers
20
views
The wp-admin url for each site does not work on WordPress multisite
I'm having some trouble while trying to access the admin area of each site in a WordPress multisite. I have the following settings in wp-config.php
define('WP_SITEURL','https://web.mydomain.com');
$...
0
votes
1
answer
33
views
Is it possible to use the same slug structure for a taxonomy and for some pages?
I have a taxonomy project_category, and I want the URLs to appear as:
https://www.example.com/{$term_slug}-web-design/
I can achieve this with rewrite rules, but the problem I'm running in to is that ...
0
votes
0
answers
25
views
URL rewriting problem
He guys,
I would like to rewrite URLs like the following one:
https://my.domain/blog/2023/09/18/newsname
to the following
https://my.domain/newsname
So, category (and maybe even subcategory) and date ...
1
vote
1
answer
25
views
What's the best way to complete links on a certain WordPress Page with everything after the slug?
I'm looking for the optimal approach to replace all links on a WordPress page with the segment that follows the page's slug. Currently, I'm encountering an issue where accessing the page with an ...
0
votes
1
answer
12
views
Settings > Permalinks - mod_rewrite ineffective if expression not preceded by /index.php/
I can not customize my WordPress permalink structure on my development server and have the URL's point to my desired pages, unless the permalink structure includes /index.php/ at the beginning of the ...
1
vote
1
answer
132
views
Add rewrite endpoint and .htaccess
I'm trying to make a redirection with .htaccess and rewrite endpoint (add_rewrite_endpoint()) and it's working but at the time of redirection it adds a /1/ to the route and I don't understand where it ...
1
vote
1
answer
36
views
URL Redirect on GoDaddy platform [closed]
I am the IT support person for one of our clients. We have a domain hosted on GoDaddy in one account pointing to a WordPress site located in another GoDaddy account created by our client.
In the DNS ...
1
vote
1
answer
320
views
How can i redirect one url to another url using .htaccess or add_rewrite_rule
I am stuck at redirecting one url to another url.
I want to redirect
https://samedomain.com/page-check-927GSJAYS639AL/highlights
to
https://samedomain.com/page-highlights/
(927GSJAYS639AL this is id ...
1
vote
1
answer
141
views
Override htacces rule only for specific directory
I have a WordPress site with ithemes security installed plugin. I want to disable this rule:
RewriteCond %{HTTP_USER_AGENT} "^$" [NC,OR]
only for this wp-content/uploads/xmls directory.
...
1
vote
1
answer
2k
views
Change htaccess to redirect to index.php in subfolder
How can I change the WordPress root folder .htaccess file to redirect URLs with a specific subfolder to its own index.php and give the path data as a URL variable to the index.php?
https://example.com/...
1
vote
1
answer
130
views
Can I write 'RewriteCond' using 'functions.php'?
I want to add 'rewrite condition' in .htcaccess but unfortunately I don't have access of that.
Can I write conditions in functions.php ? If yes, how to achieve that ?
I want to add these lines:
...
2
votes
1
answer
102
views
How to create a 301 redirect that doesn't apply to subsites
Scenario:
I'm trying to set a 301 redirect so that https://foo.org/events is redirected to a non-WordPress site https://bar.org/events.
On my .htaccess file, I set the following:
Redirect 301 /events ...
2
votes
1
answer
19
views
Menu links only using http after enabling https, unable to redirect http links
I have a WordPress website on a Bluehost shared hosting server and since I have multiple websites in my space, I have this particular folder in its own folder under public_html. This means that I have ...
1
vote
1
answer
3k
views
Adding rewrite rules directly to .htaccess file
I wanna add a simple rewrite rule
RewriteRule ^apply\/? https://docs.google.com/forms/d/e/1FAIpQLSf5IrOhg0E_NAGZnOvMuaXhU80sio8bukaWVBkb87eEOa9kTw/viewform [L]
my .htaccess file is like
# BEGIN ...
0
votes
0
answers
78
views
Rewriting subfolders to specific parent folder in Wordpress
I have created one page with name /parent/ and assigned new template template-parent.php that has some 3rd party software showing via JavaScript. I need to rewrite all subfolders to this parent so ...
1
vote
1
answer
348
views
flush_rewrite_rules() not working with update_option_{$option}
Will someone please explain to me why flushing doesn't work in my case. I added a custom settings page with a default value, but it doesn't work when I hit save changes.
I use the admin_init hook to ...
1
vote
0
answers
145
views
Rewrite custom post type URL parameters
I would like to change the following parameterized URL:
www.example.com/category/?keywords=&location=new-york&type=Wedding
in this way: (invert city > category)
www.example.com/category/...
1
vote
1
answer
641
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 ...
2
votes
2
answers
234
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
1
answer
1k
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
0
answers
45
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
0
answers
47
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
1
answer
106
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
0
answers
26
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
2
answers
287
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\....
2
votes
1
answer
615
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
1
answer
543
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
1
answer
222
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
2
answers
219
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
0
answers
41
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. ...
0
votes
2
answers
2k
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 ...
1
vote
1
answer
96
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
1
answer
92
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 ...
2
votes
1
answer
320
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 ...
4
votes
1
answer
2k
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, ...
1
vote
1
answer
179
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
0
answers
262
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
0
answers
303
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
0
answers
533
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
0
answers
52
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
1
answer
2k
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
1
answer
4k
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
0
answers
209
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
0
answers
51
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
1
answer
510
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
0
answers
51
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
0
answers
80
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
1
answer
117
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 ...
0
votes
1
answer
1k
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 ....