Wordpress Rewriterule / Redirection - .htaccess

Guys i'm facing an issue regarding wordpress redirection.
I've used .htaccess on my website and i wish to make this work also for wordpress pages.I've installed wordpress in a folder named as "blogs" on the root like /blogs
I've also integrated/made changes in search.php of wordpress (domainname.com/blogs/wp-content/themes/my_theme/search.php) to my requirements. When someone searches the form action goes some thing like this:
http://www.domainname.com/blogs/?s=keyword
This works fine but I want to use rewrite rule over this something like:
www.domainname.com/blogs/blog-keyword with http://
but it brings user to 404.php page of wordpress
my current htaccess file contains the following code under the blogs directory of root:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blogs/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blogs/index.php [L]
# Pads Landing / Searching Page
RewriteRule ^blogs/movie-(.*) /pads/?s=$1
</IfModule>
# END WordPress
Kindly help me I've few mins left for project deadline.
Thanks in advance.

Ok...
Check into Options -Multiviews
I've noticed issues when using wordpress
I use it like so
Options +FollowSymlinks
Options -Multiviews
RewriteEngine on
So
RewriteRule ^pads/movie-([^/]+)$ "http://%{HTTP_HOST}/pads/?s=$1" [R=301,L]
Hope it works. Lemeknow

Related

URL Rewrite Rule shows blank page with text

i'm learning how to rewrite urls and im trying to do that in my ubuntu server. I managed myselft to activate the Allowoverride All and i have htacess working.
I want to change this url for example:
http://serverismai/myapi/public/rest/navigate.php
And i try to do it like this :
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^home(.*)$ myapi/public/rest/curso/navigate.php/$1 [L]
</IfModule>
I've tried various solutions but this was the closest i got. The url dosent change automatically but if i insert http://serverismai/myapi/public/rest/home i see a blank page with some of my website html written ( not even the html of the page i'm trying to rewite url).
I'm pretty new to this so i want to know if there is something wrong in the Rewrite Rule or if my error is somewhere else...
Thank you!
You can use this code in your /myapi/public/rest/.htaccess file:
RewriteEngine On
RewriteBase /myapi/public/rest/
RewriteRule ^home/?$ curso/navigate.php [L,NC]

Index.php does not load automatically when site is opened

I uploaded to my wordpress files, have gotten all the configuration issues straightened out and it now works fine, but only if I enter the full address - www.mydomain.com/index.php
If i try to enter just www.mydomain.com it does not load.
Why is it not automatically loading index.php when the site is accessed?
Default wordpress .htaccess is this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Make sure to drop that into the same directory of your site that contains the wp-content etc. folder.
If that doesn't help, then check in your general settings to make sure that your website isn't pointing to /index.php etc. Example screen below:
Add this to your .htaccess, so it looks something like this at the end:
RewriteRule . /index.php [L]
</IfModule>
DirectoryIndex index.php Index.php
# END WordPress
This htaccess snippit is based off the one Ian says is default for wordpress. It may vary for Plsek Panel. This is another page that could help: http://support.hostgator.com/articles/specialized-help/technical/apache-htaccess/directory-index-for-plesk-for-linux
(This post has been edited beyond recognition from its original state)

.htaccess RewriteRule seems not to work

I got a problem with my .htaccess here and altough I searched the web and tried many things, I could not find any solution...
I have a wordpress-installation with enabled permalinks. Additional to that, I need to rewrite another URL on this wordpress-installation, which does not belong to WP.
If a user browses to http://www.URL.com/?page_id=30&tag=all&filterCategory=6\%23Jackets, I'd like to show http://www.URL.com/jackets.html as URL. There should also be the possibility to directly browse to http://www.URL.com/jackets.html.
My .htaccess looks like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^jacket\.html$ http://www.URL.com/?page_id=30&tag=all&filterCategory=6\%23Jackets [L]
</IfModule>
# END WordPress
Does anyone have any idea why this does not work?
The WordPress rewrite rules are redirecting any requests to non-existant files through WordPress. The rewrite rule responsible for this, RewriteRule . /index.php [L], is marked with [L], indicating that no more rules are to be processed after it. In order for your rule to work, it must be placed before the WordPress rules, but after the line RewriteBase /.

Redirect subdir with .htaccess

My first question here! :) Hello!
I have some trouble with .htaccess.
http://www.domain.com/subdir/?parameter=example works.
http://www.domain.com/subdir/example doesn't work.
When i try this:
RewriteBase /subdir
RewriteRule ^index.php - [L]
RewriteRule ^([^/]+)/?$ index.php?i=$1 [R,L]
i get an 404.shtml error like http:// www.domain.com/subdir/index.php?i=404.shtml
Also the wp-admin(http:// www.domain.com/wp-admin/) redirects to the subdir with 404.shtml. How do i get the url like http:// www.domain.com/subdir/example/
Can anyone help me?? Thnx in advanced!
Assuming this is a WordPress installation (based on the mention of 'wp-admin'), you want the following
Just use the WordPress standard, put this .htaccess into the root folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdir/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdir/index.php [L]
</IfModule>
Go to Settings and change Site address (URL) under General Settings to http://www.domain.com/subdir/
Put the following index.php into the root folder
<?php
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require('./subdir/wp-blog-header.php');
?>
Go to Settings > Permalinks and change the permalink structure to whatever you need
p.s. to access wp-admin you need to navigate to http://www.domain.com/subdir/wp-admin/
more info here: http://codex.wordpress.org/Moving_WordPress#Giving_WordPress_its_Own_Directory_While_Leaving_the_WordPress_Index_File_in_the_Root_Directory

what do I need to do to fix my cakephp routes

currently when I click a link in on my website it is creating a url that looks like this
http://domainname.com/app/webroot/index.php/links
this causes the page to load incorrectly. if I edit the url by hand to look like this
http://domainname.com/links
everything loads correctly. My three .htaccess files look like this
/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
app/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
app/webroot/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
is there something I need to change in here? am I supposed to make these changes somewhere else? This site is hosted on godaddy's shared hosting. I don't know if that has anything to do with it.
UPDATE:
here is the link.
<?php echo $this->Html->link('Portfolio', array('controller' => 'images', 'action' => 'index'))?>
I've also tried removing the RewriteBase / line from all of the files. That didn't help.
also this is what is in my routes.php file.
Router::connect('/', array('controller' => 'posts', 'action' => 'index'));
Try taking out all the RewriteBase lines
Couple of things you can check:
mod_rewrite is available and working
Apache config allows
these options: Indexes MultiViews FollowSymLinks
RewriteBase in
your .htaccess actually rewrites to the correct dir if you have
multiple cakephp apps. E.g. I have to use RewriteBase
/~shaz/webapps/myapp/
Also there's loads of posts on google and even on stackoverflow so it might be worth ensuring you have the same "default" settings / environment as someone else, and working your way from there.
If all else fails, you can use the alternative "pretty" url setting provided in the config/core.php file.
I had to comment out the following line in the core.php file.
Configure::write('App.baseUrl', env('SCRIPT_NAME'));
I forgot that I had to uncomment it to get things working on my development server.

Resources