A have a wordpress theme, which has a built-in services module. All items in that can be found at domain.com/services/item. I rewrote a php file so links to these service items look like domain.com/something-else/item, but they point to the 404 page.
I would like to modify my site's .htaccess file to display the original domain.com/services/item content while users see domain.com/something-else/item.
I would like to use the url (something-else) instead the other(services) one, while keeping content the same.
Ha can I achieve this using .htaccess?
Just use the buit-in Rewrite API of wordpress :
http://codex.wordpress.org/Rewrite_API
Example : http://www.hongkiat.com/blog/wordpress-url-rewrite/
Related
Consider the following post types
Posts (default in WordPress)
Accessories (Custom post type)
I want posts to go to /blog. Accessories slug has been defined as /accessories.
To achieve this, in settings > permalinks > and have defined my custom structure as /blog/%postname%/.
With this, when I go to /blog/, I get a 404. However, when I create a post in posts, the permalink shows up as /blog/test-title.
Also, with the custom structure set, when I try and go to /accessories, it also 404's.
Questions:
Why does /blog 404? It should use index.php as it's template, no?
Why does /accessories 404 with this change?
How do I get /blog and /accessories working?
To get this WordPress permalink stuff to work correctly, the underlying apache web server grabs the incoming URL requests and rewrites them underneath the covers so they point to /index.php?something=something. For this to work, apache must
have an extension module called mod_rewrite enabled,
be configured to allow rewriting in your WordPress instance, and
be able to write a file called .htaccess in the same folder as your WordPress index.php.
You didn't mention what kind of OS your server lives on, so it's difficult to give you specific advice. You might check Digital Ocean's fabulous documentation for help.
I am trying to understand how the URL resolution happens in WordPress. When a page is created/edited the internal link is something like the following:
example.com/wp-admin/post.php?post=165&action=edit
But to view the page, the URL used is something like the following:
example.com/about-us
How does WP resolve the public URL and generate the page?
As far as I can tell WordPress does this resolution using the .htaccess file. The rules are set in .htaccess to route the request to an index.php file which does the rest of the processing to generate the page.
This is specific to Apache. Other web servers may do it differently.
i have a wordpress site let just call it testing.com
with a page url called blog/ which can access via testing.com/blog
i am using NGINX as the web server.
How do i rewrite the testing.com/blog to blog.testing.com with all its content still intact?
//edit
in this case, /blog is a page in the wordpress and not the wordpress itself, only that page and all the link inside the page would be rewrite to the subdomain and nothing else
example:
inside of the blog.testing.com there was 2 more link such as:
1. older post
(original link will be testing.com/blog/page/2 and change it to blog.testing.com/page/2)
1. read more on each post
(original link will be testing.com/2017/05/testpost1 and change it to blog.testing.com/2017/05/testpost1)
//end of edit
so as to say as if i am opening testing.com/blog in blog.testing.com
i have tried rewrite and proxy pass
location ^~ /blog/ {
rewrite ^/admin(.*) http://blog.testing.com$uri permanent;
}
with the above block
the result is same as return the url only and not with the supposed content.
or is it not possible to do so?
Hi assuming that you don't want to keep the URL testing.com/blog at all and instead want to use the subdomain blog.testing.com then effectively what you want to achieve is a WordPress migration. There are a number of ways you can achieve a migration, depending on how technically able you are. The easiest way is probably to install and use a WordPress migration plug in such as WordPress Duplicator or WordPress Move. Please take a backup of your files AND database before you start.
The official WordPress guide to migration can be found at https://codex.wordpress.org/Moving_WordPress
In short you would create the subdomain, then move (migrate) the site that's currently at testing.com/blog to the subdomain blog.testing.com
If the subdomain directory is to be left at /blog and you are just pointing the subdomain to that directory, then you might be able to do what you need to do just by updating the database to reset all the internal URLs in the WordPress database. In this case you could consider using https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
This is what I tend to use when migrating sites from test to live. Hope this helps.
I have a Magento site installed at the root of my domain and a Wordpress installed in a subdirectory. Currently I access my sites like this:
Magento: "domain.com"
Wordpress: "domain.com/blog"
I would like to be able to use Wordpress Pages seamlessly, without the "/blog" subdirectory showing in the url, such as:
Wordpress Page-X: "domain.com/page-x"
Note that I do want to keep the "/blog" subdirectory showing normally for blog posts etc... I just don't want it for Wordpress Pages.
Could anybody help on how to set that up? I was think tweaking the .htaccess would've work, but I can't find out how. Other solutions are welcome too. Thank you.
Magento provides you with an option to create custom URL rewrites in the backend (admin) you can find it here. This way you should be able to create rewrites. Also if you want to automate the creation of rewrites you can refer to the core_rewrites table in magento's database. Also this is a good read if you want to do logic based rewrites on the fly.
I have a page (shop) in my drupal 7 site. On this page is a php script requesting a webservice.
The response depends on the URL, eg. /shop/pid-1234/pink-shoes.html will show a product with id 1234.
I therefore need Drupal to load the /shop page no matter what the URL after shop/ looks like. How do I
achive this? I have tried using wildcards in the URL alias module ($,%) but that didn't work. I have also
looked at pathauto and redirect, but didn't seem like they could help.
Any suggestions?
You probably need an Apache mod_rewrite rule. You can add something to your .htaccess file if you're using one.