There's often a need to use images in the Wordpress theme folder for other uses (for instance in an email).
These URLs take the form;
http://example.com/wordpress/wp-content/themes/mytheme/images/image.jpg or
http://example.com/wordpress/wp-content/uploads/path-to-my-image/image.jpg
What sort of redirect in htaccess would I need to use a simple url
http://example.com/images/image.jpg?
I am, of course, assuming http://example.com/images isn't used for anything else.
I'd say something like this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} images/(.*)$
RewriteRule ^.*$ http://example.com/wordpress/wp-content/themes/mytheme/images/%1 [L,R=303]
Related
I've read up on several posts here and elsewhere regarding very similar questions (this one probably being the closest). The catch with our situation is that I don't want WP to be a blog that is appended to our app, but rather the thing people see when they hit our URL. The problem, of course, being that Codeigniter, since it's in the root whilst WP is in /wordpress/, has its index.php in the root. For me to set WP up to read as root without it being such requires it's index.php to be in the root.
Any ideas besides moving our application portion into a new directory? Have tons of user activity at the moment that is mission critical so don't want to fool with potential downtime, conflicts, etc. Basically we want to not touch the app if at all possible and simply have people not logged in route to the WP marketing site without seeing /wordpress/ in the URL.
Thanks for any pointers!
Basically we want to not touch the app if at all possible and simply have people not logged in route to the WP marketing site without seeing /wordpress/ in the URL.
If your main app handles authentication, you're probably using a cookie to store an authentication token. Your can use this cookie in your .htaccess in order to determine how the URL is rewritten. Something like this should work:
RewriteEngine On
RewriteBase /
# if auth cookie is not set, use /wordpress/ routes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_COOKIE} !^.*authcookiename.*$ [NC]
RewriteRule ^(.*)$ wordpress/index.php/$1 [L]
# otherwise, use the codeigniter routes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
There are two caveats:
This might cause issues with wordpress routes for static resources. You might need to finagle with some RewriteConds and the Wordpress config to make this work properly.
Assuming you aren't already, you need to edit config.php such that:
$config['index_page'] = '';
This is either blindingly simple or impossible; after lots of Googling and thread reading, I can't tell.
I have a WordPress site that uses a plugin to create a custom post type. The rub of this is that the custom post type has a very ugly "slug". What this means is that the URLs look like this:
http://mysite.org/uglyname/a-post-title/
Where "uglyname" is an ugly name. I can't change the name without editing the core files of the plugin, which is a bad idea in this context.
What I'd like to do is make it so that if a user visits a URL like this:
http://mysite.org/prettyname/a-post-title/
Wordpress interprets prettyname as it would uglyname and is more or less nonethewiser.
I don't want something that just redirects; I'd like it to be a silent mapping. But keep in mind that Wordpress is already using the .htaccess file to map everything it gets onto http://mysite.org/index.php.
Is this possible, or am I just barking up the wrong tree?
EDIT to add: The current .htaccess is the WordPress default:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mysite.org/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite.org/index.php [L]
</IfModule>
# END WordPress
Just above RewriteCond
%{REQUEST_FILENAME} !-f, try the following line:
RewriteRule ^prettyname/(.+)/? /uglyname/$1
If I'm not mistaken, it should pass it over, and then still process the index.php routing.
Haven't tested it - not at a server right now.
I am trying to rewrite everything by appending a language code at the beginning of the path. When I use this: RewriteRule ^(.*)3$ es/$1browsing mysite.com/admin3 properly loads mysite.com/es/admin.
But i do not know why, but when I use this: RewriteRule ^(.*)$ es/$1
browsing mysite.com/admin does load mysite.com/es/admin BUT it loads so slow, and in plain html (no css, no images, etc).
Can somebody point out what am I doing wrong? It's driving me nuts - i', a regexp noob.
Thanks.
UPDATE:
We already have a multilingual site running. But we wanted to provide alternative access to the other languages via local domains. So we wanted to have mysite.com/es while having newdomain.es at the same time. This is not possible via Drupal's "domain name" language negotiation.
Now I've already setup newdomain.es/es but I want users to only see newdomain.es on the address bar.
I just realised that one could use the subdomain option from Drupal internationlisation under /admin/config/regional/language/configure.
If you choose [configure] next to URL, you can enable domain prefix like es.mysite.com.
And then you can point your DNS of mysite.es to es.mysite.com. Just add to DNS of mysite.es the value www - CNAME - es.mysite.com (Note that sometimes you might need an extra dot in the destination like www - CNAME - es.mysite.com.).
The problem I was having was that, files are also forwarded (e.g, css, javascript, images, etc). This is how I solved it:
RewriteCond %{HTTP_HOST} ^mysite.es$ [NC]
# optional: add other language exceptions so they still work
# RewriteCond %{REQUEST_URI} !^/fr/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ es/$1 [NC,QSA]
# for homepage
RewriteCond %{HTTP_HOST} ^mysite.es$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ es
i have a wordpress site that currently shows the posts like
http://mysite.com/index.php?p=1
and now i wanna access the same thing by writing url as
http://mysite.com/1
what can be the rewrite rules to do that.. i saw the .htaccess that hides the index.php from the url and regular expressions but was not being able to properly do what is needed!
In the htaccess file in your document root, preferably before any wordpress related rewrite rules, add these:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([0-9]+)$ /index.php?p=$1 [L,QSA]
Are all requests handled in index.php?
Yes. All* requests will go through index.php there is a rewrite rule in the .htaccess file which masks this and gives user friendly urls.
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
If Drupal can't invoke these rules then you will see index.php in the browser URL.
**There are cron.php and update.php which don't but these are special files for admin so are not part of the run of the mill site.*
Yes. If you're looking for certain code snippets that handles URL parsing and calls various modules then take a look inside bootstrap.inc