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
70
votes
2
answers
122k
views
How can I create custom URL routes?
I have a very peculiar requirement, but hopefully I can explain it without being too confusing. I created a page template where I list some properties I get from an external XML file. So far no ...
28
votes
2
answers
112k
views
remove "index.php" from permalinks
I have been trying to find a solution. but I can't..
my links are all domain.com/index.php/post_name/
I really want to remove /index.php
I have searched and found some... saying I need to add these....
13
votes
1
answer
7k
views
Change permalinks for posts but not for custom post types
Currently my permalink structure for posts is
domain.com/post-title
I'm using a static front page and a "blog" page for posts. I'd like to to change the permalink structure for posts, tags and ...
10
votes
3
answers
13k
views
Masking wp-content/themes/name/images to just images directory using htaccess
I'm trying what I thought would be something really simple of masking my url but cannot seem to get it to work. I want to be able to link to images in my img tag without having to type in the full ...
9
votes
3
answers
9k
views
Change author permalink
The original urls for users look like /author/login/
Is it possible to replace login by user's id?
In my dream urls should become to /users/34/ (34 is user id).
Thanks.
8
votes
1
answer
5k
views
How to remove dates from existing permalinks?
After doing some research about dates on blogs, it seems like it is a good idea to remove them from the existing posts.
Consider:
Self-hosted (on Bluehost)
Over 1,000 existing posts
All posts are ...
7
votes
2
answers
12k
views
Making a plugin file accessible via url rewrite?
In my WordPress plugin I have a php file that generates some stats about the blog and outputs it as a simple text file. To access WordPress functions I've included this at the top of the file:
define(...
7
votes
1
answer
3k
views
Hosting a Wordpress blog as a sub folder from a S3 website
I have a website set up for my organisation under www.mycompany.com (running on Amazon S3). I also have a Wordpress blog set up under blog.mycompany.com (running on a separate LAMP server).
For SEO ...
5
votes
2
answers
376
views
My permalinks are broken! Can I use mod_rewrite to ignore a physical file?
A website I work on recently posted a file at the root of their website named "2011.html." Now, any 2011 blog posts with the permalink structure of year/month/day/post-name do not work, and instead ...
4
votes
2
answers
3k
views
mod_rewrite enabled but Permalinks show index.php
I just installed a friends blog on my LAMP stack, which has mod_rewrite enabled (I'm using it for clean URLs on my Drupal installs on the same server). For some reason, WordPress (3.0.3) isn't ...
4
votes
1
answer
5k
views
".#[random-char-string]" being inserted at end of URLs
I've seen this on a couple of sites now and I'm having trouble finding information about (probably because it's awkward to describe):
All internal URLs like this for example:
http://www.domain....
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..
...
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, ...
4
votes
1
answer
2k
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:
<...
4
votes
1
answer
6k
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....
3
votes
2
answers
39k
views
404 when fetching image from wp-content/uploads/
I get 404 status when fetching images, and the http still contains that image. Image shows up in a browser, but the 404 code breaks some applications.
calls to wp-content/uploads/ are redirected in ....
3
votes
5
answers
2k
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:
&...
3
votes
2
answers
4k
views
How to map permalinks with accented letters to sanitized slugs?
To keep legacy entries on a blog hosted on TypePad on sync with a new WordPress installation...
How do I map this permalink with accented letters:
domain.com/no-es-fácil-alejarse-de-la-política
to ...
3
votes
1
answer
3k
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.
3
votes
2
answers
5k
views
Clean URLs for custom $_GET variables
I have a query var show=othertemplate that I can add to any URL to show any post, page or archive in Wordpress in a different template, like this: mysite.com/[any URL]/?show=othertemplate. I'd like ...
3
votes
2
answers
1k
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 ...
3
votes
1
answer
605
views
Bypass .htaccess when using download_url
I've got the following .htaccess file in my a custom directory in Uploads called client.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !(www.)?example.co.uk/client-area*
RewriteRule ^.*$ - [R=403,L]
...
3
votes
1
answer
329
views
Removing rules from .htaccess
I'm writing a small plugin that needs to write to .htaccess a simple non_wp_rule and i am doing it like this:
function ci_flush_rules()
{
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
...
3
votes
1
answer
485
views
Sub domain redirection to taxonomy
Hi all I want to use sub domain for my taxonomy like that :
http://taxonomy.domain.com/apple map to http://www.domain.com/taxonomy/apple
I add this to my vhost
RewriteCond %{HTTP_HOST} ^...
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 ...
3
votes
2
answers
1k
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.
...
3
votes
0
answers
733
views
WordPress URL/Folder ReWrite using Htaccess
I am trying to mask certain folder in a WordPress installation using the Htaccess file. I am aware that there are plugins available to do exactly what I want but, I do not want to add even more ...
3
votes
0
answers
401
views
Evaluating a external rewrite rule before internal wordpress rewrite rule
I am been plucking out my hairs since last few days trying to solve this problem:
I want to convert my urls from format
http://example.com/prodsearch/category/tag1-tag2-tag3-tag4
to
http://...
3
votes
1
answer
5k
views
Wordpress multisite causing Error 101 (net::ERR_CONNECTION_RESET): Unknown error [duplicate]
Possible Duplicate:
WordPress upgrade now receiving Error 101 (net::ERR_CONNECTION_RESET): Unknown error
We have just installed WordPress 3.0.1 and everything worked fine. However, as soon as we ...
2
votes
2
answers
311
views
Can WordPress be installed at the root level, if a homepage called index.php already exists?
Can WordPress be installed at the root level, if a homepage called index.php already exists?
2
votes
2
answers
2k
views
Remove base slug in permalinks of hierarchical custom post type
I have a hierarchical Custom Post Type called project, registered as follows:
register_post_type( 'project',
array(
'public' => true,
'hierarchical' => true,
...
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 ...
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-...
2
votes
1
answer
616
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 ...
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 ...
2
votes
2
answers
7k
views
Should I enable FastCGI on WordPress?
I am looking at my server settings and these are as follows:
WebDav : active
FastCGI : inactive
SSL support : active
Perl as Apache module : CGI-Programm
PHP module : CGI-...
2
votes
1
answer
907
views
WordPress mod_rewrite is canceling/overwriting my other mod_rewrite rule
in /www/ I have an .htaccess file containing:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^.]*\.less)$ compilers/lessphp.php?file=$1 [R,QSA,L]
</...
2
votes
1
answer
5k
views
How to rewrite WordPress uploads folder to another folder using htaccess
I found that the following code online could be used to spoof the WordPress uploads folder, rewriting URLs to a different folder on the server:
# BEGIN Spoof wp-content/uploads directory
...
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 ...
2
votes
1
answer
210
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.
...
2
votes
1
answer
4k
views
Custom rewrite rule, url returning 404
I have a custom URL like this:
website.com/show/?id=9999&n=page-name
and I'm trying to come up with a mod_rewrite rule to convert to
website.com/show/9999/page-name/
/show/ is a page name.
...
2
votes
1
answer
210
views
Using custom post type parent as slug
I'm currently using the plugin 'Types Custom Post Type' to create custom post types (I know it's pretty easily done through functions.php but I was feeling a bit lazy!).
Basically, I'm looking to ...
2
votes
2
answers
2k
views
How to protect media directory with .htaccess?
I am trying to protect the uploads directory with .htacess.
But when I browse media section in admin panel, I see user/pass popup.
My guess is, WordPress use fopen to find if the file exists. I ...
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
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
...
...
2
votes
1
answer
795
views
add new permalink structure from dynamic page
I created page "play" url: http://localhost/myweb/play and inside of page "play" I include PHP code to make the new search from outside Wordpress.
And all worked, if I search from my page "play" the ...
1
vote
3
answers
4k
views
Need to make a php file inside theme accessible via url
I checked this post here Making a plugin file accessible via url rewrite? which seems to have the same problem as me but its for a plugin. But so far i am getting 404.
add_action( 'init', 'my_rewrite'...
1
vote
2
answers
1k
views
Using custom mod_rewrite without breaking wordpress permalinks
I am using a theme that uses posts for multiple pages, and the blog posts goes in a category called "blog", I am using the permalinks setting "/%postname%", and the blog menu url is "/category/blog", ...
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 ....
1
vote
2
answers
617
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 ...