Could someone help me; where am i doing wrong?
My wordpress site is not in root; i installed it in a directory(newsite/) I mean; there are 2 sites.
My root site(example.com) has default htaccess file.
And this is my sub wordpress site's(example.com/newsite/) .htacces source:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /newsite/
RewriteRule ^newsite/news/hello-world /newsite/news/?title=hello-world [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /newsite/index.php [L]
</IfModule>
# END WordPress
I just want:
www.example.com/newsite/news/hello-world
(above url should open the url at below; without url change at address bar)
www.example.com/newsite/news/?title=hello-world
Check with different permalink options.
Note : .htaccess file should be writable or paste the suggested code in .htaccess after permalink saved.
Related
I know how to change URL in PHP but I am not an expert in WordPress.
I have this URL:
domain.com/parent-page/child-page-here/?id=SomeText
and I want this
domain.com/parent-page/child-page-here/Some Text:
I changed .htaccess but its not working here is my .htaccess code
# 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
RewriteEngine On
RewriteRule ^parent-page/child-page/([0-9a-zA-Z]+) parent-page/child-page/?id=$1 [NC,L]
No need to use the .htaccess as Wordpress comes with the feature you are required. All you have to do is change the permalink as here from the admin dashboard.
#mapmalith is correct, with WordPress you can simply change the permalinks in your settings.
However, if for whatever reason you're unable to do this, then you can use the following inside your .htaccess file:
RewriteEngine On
RewriteRule ^parent-page/child-page-here/([^/]*)$ /parent-page/child-page-here/?id=$1 [L]
It will leave you with the following URL: domain.com/parent-page/child-page-here/SomeText. Just make sure you clear your cache before you test this.
Obviously you will need to rename the directories to the correct names.
I've WordPress site with the URL :
http://thelaptopsolutions.in/Laptop%20Solution/
This is working fine but the URL now shows http://thelaptopsolutions.in/Laptop%20Solution/ but I want it to show http://thelaptopsolutions.in
Here's my current htaccess code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Laptop%20Solution/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /Laptop%20Solution/index.php [L]
</IfModule>
# END WordPress
Thanks in advance..
I advice you against messing up the contents of the .htaccess file. Revert the changes that you've made to this file and follow the simple procedue.
Login to the admin dashboard.
Go to Settings > General
In the WordPress Address (URL) field type http://www.example.com/site
In the Site Address (URL) field type http://www.example.com
Save the changes and you should be good to go.
I would like to have a multilingual website but I haven't finished english version yet so I would like to redirect if url has /en/ to a specific page with a content "Soon". This page would be www.sitename.com/en/welcome
I am doing this in Wordpress and I don't know .htaccess that good. This code actually works pretty good, it checks for language set and redirects accordingly, but the problem is that after visiting that url I want to go to www.sitename.com, it still redirects me to that page (probably since locale doesn't change).
add_action("template_redirect", 'pl_redirect');
function pl_redirect() {
// if is english redirect to page id 193
if (get_locale() == 'en_US' && !is_page(193)){
wp_redirect( 'http://www.sitename.com/en/welcome' );
exit;
}
}
How can I accomplish the same thing correctly?
I tried this in .htaccess but it doesn't work
Options +FollowSymLinks
RewriteEngine on
Redirect 301 ^/en/$ /en/welcome
This is by Wordpress inside .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php [L]
RewriteRule ^/en/$ /en/welcome [R=301]
</IfModule>
Assuming you have actually installed everything in a directory called /web - you'll need 2 .htaccess files:
/.htaccess (the root WordPress .htaccess file)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# the base directory
RewriteBase /web/
# this means "don't rewrite /web/index.php"
RewriteRule ^index\.php$ - [L]
# this is a router any URL that's neither a file
# nor a directory will be routed to /web/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php [L]
</IfModule>
/web/.htaccess (your rewrite)
RewriteEngine On
RewriteRule ^en/?$ /web/en/welcome [NC,L,R=302]
God, this little problem drives me crazy and I really hope that you'll help me how to figure it out.
I searched over all previous threads and in the codex of wordpress, didn't find my exact problem.
This is it :
I've one host with a wordpress installed at the root. I've one domain pointing it. Everything is fine.
I've need now a second install of wordpress, that i've installed in a subfolder. I've a second domain, linked to this subdfoler.
Like this :
root > domain.net
root/subfolder > anotherdomain.net
If I let the "site url" setting and the "wordpress url" setting with "domain.net/subfolder", this is OK, I can access to my second site and all permalinks work.
But if I edit my site url/wordpress url in "anotherdomain.net" it renders the "domain.net" homepage without style...
I'm sure this is a question of HTACCESS but I can't find how to properly write it...
Thanks for your answers !
(sorry for my english, not my mother tongue)
EDIT : Here are .htaccess (at this state, I let them in order to access subfolder via domain.net/subfolder)
root:
# 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>
root/subfolder
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]
</IfModule>
# END WordPress
HTACCESS would be my first guess too, but another thought occurred to me: have you made sure that you are installing the two sites in two distinct SQL databases?
Assuming this is not the problem, is there any way you paste your htaccess files, so I can see if there is an issue in them?
All the config were good, the problem was with my host provider.
For the record, the htaccess for the site in the subfolder, when everything is ok :
# 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
And the site and wordpress urls pointing to the new domain.
We have a site running on WordPress ada.localhost.com
Now all request to base url (http://ada.localhost.com/) have to go through tracking page (track.com/c/0912321323/?u=xxx) where u parameter is where to redirect user after he is tracked.
I've created a copy of index.php (index2.php) and I want to create htaccess rule to redirect all base url traffic to:
http://track.com/c/0912321323?u=http%3A%2F%2Fada.localhost.com%2Findex2.html (http://ada.localhost.com/index2.php)
Typical WP htaccess file looks like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any clue on how to set it up and if WordPress allow this configuration?
From what I found WordPress won't work with index2.php.
Solution for this is to write a plugin which deals with it.