Let's say I publish a page in WordPress and it generates a url like this.
mydomain.com/pagestructure
I need to have this structure
mydomain.com/page/structure
I figured several ways of doing that.
Edit url from the page edit screen
Edit permalink structure and use Custom structure there
Edit .htaccess
I can't use the second method because I need this structure only for a single, particular page. Not for all pages.
I can't use third method as it is a bit difficult for me. Sorry for that.
The first method is I want to use as it is the most simpler one. But I am not able to use it because WP does not allow putting "/" at desired places. It re-writes them. If by somehow I prevent the re-writing of "/", maybe via adding a rewrite rule via "add_rewrite_rule", it might solve the problem. Any help?
Related
I'm currently looking for a way to change / hide the default WordPress admin-ajax.php URL. I want to do this to remove the admin from it to prevent misunderstandings by my customers when I use the AJAX URL to read for example a file from my server. In this case, the URL has the admin prefix which is a bit confusing.
So in result the AJAX URl should looks like this: ajax.php
I've searched a bit but I can't find any helpful information. Because of this I can't show you any related code. But when I got it, I'll update my question to help other people.
Alternatively and perhaps more effectively you could leverage WP API and create a custom endpoint to process your data so that there isn't url confusion.
We want to have as much simple as possible referral links to our site for users. The best to have something like: example.com/username
But in this case we need to invent some way to make all other links working in WordPress. The idea how to implement it using mod_rewrite should look like:
If no any parameters provided - rewrite to / and process index.php
If parameter provided represented in site structure with file or directory - rewrite to example.com/parameter and show the content from site.
If link contain /s/ (example.com/s/something) then it's our post, which we should translate to something which allow us to see a post.
If one parameter provided - rewrite to example.com/parameter and process example.com/index.php?ref=parameter
Question is: Will it work for all plugins (at least woocommerce and some other) or is it possible to implement at all ? I really don't know how permalink and other wordpress part is working.
Thank you for your ideas.
Is it possible to have something like this in wordpress:
http://example.com/post/2135/post-name
without having to rewrite my current url structure which is
http://example.com/post/2135
I want to keep it, and be able to access posts both ways. With and without the post-name
is it possible to have it that way? maybe make wordpress ignore that there's the post name attached at the end?
i believe it is in the php.ini file
example,
me.com/boss
file structure
root/boss/index.php
the index.php file will auto load.
but if you are used MVC you can change the results of what is displayed.
but
can you use http://example.com.post/2135/index.php&postname=lol
I currenlty have a MODx website setup, and I am wondering if it's proper to have my links look like this (And by that I mean my resource alias):
myurl.com/help/configuration/basics.html
Putting the slash in the URL like that... is it a bad practice? My main problem is that this breadcrumb plugin seems to no longer work... :(
I want to have this breadcrumb plugin operational again, if someone would mind helping me.
The Error:
When say using the breadcrumb to link to a page that's myurl.com/code/landing.html and the current page is myurl.com/help/configuration/basics.html, it will then redirect you to a link that doesnt exist, that looks like this:
myurl.com/help/configuration/code/landing.html
As you can see, it is appending the latter portion of the new page's url, but it is not properly removing the URL of the current page, as it only removes the current URL up to the '/' slash....
Does anyone know how to fix this? Possibly a way to make it so that instead of doing it's current "remove" and "append" thing, I can change breadcrumbs.class.php to take the value of the links as if I had clicked the link with the "view" button on the MODx manager? I'm not an expert at php, and it is a must for this to work.
Or are there other alternatives to creating the " / " effect in my links, rather than just putting it in the resource alias? (As I want the site to follow a logical, readable, order)
With all things modx, clear the cache, even if you don't think it could be the issue ~ modx is very aggressive about caching stuff.
Though this kinda sounds like maybe your base href tag may be set to <base href="" />, possibly in your templates it may look like:
<base href="[[++site_url]]"></base>
where site_url is set dynamically [it's not a system setting so don't look for it] in your /core/config/config.inc.php as $modx_base_url ... if that value is blank that could be causing the issue.
Also check your rewrite rules in your .htaccess to see what the rewrite base is. [it should be / ]
then refresh your cache... ;)
I have a perfectly good (so far) setup of wordpress of for a new website. The pretty urls are working as expected.
I have 1 dynamic page that loads content depending on the querystring:
/dynamic/?loc=england&code=uk
I wish to make this URL "pretty" as well but every-time I modify the .htaccess no changes are made. Tried everything and googled everything else - last resort. If I could get the following to work then I would be happy.
I need to make the URL look like.
/dynamic/location/england/code/uk/
Adding this to any .htaccess breaks the whole website.
RewriteRule /dynamic/(.*)/(.*)/(.*)/(.*)/$ /dynamic?$1=$2&$3=$4
What am i missing.
Thanks in advance
N
Don't add the rewrite rule to your .htaccess file. WordPress manages that file for you, so try to use built-in features whenever you can.
WordPress actually has a somewhat advanced rewrite engine that ships standard - and it's pluggable just like the rest of the platform.
The trick, though, is working with it. You'll need to register your RegEx so WordPress knows what kinds of strings to match (i.e dynamic/location/(.*)/code/(.*) => /dynamic?$loc=$1&code=$2). Then you'll need to set up the page and script on the back end to handle the submission.
For a similar example, look at the answer I received to parsing custom URLs with a custom post type over on WordPress Answers. Extending this, you'll need to set up code similar to the following (note: untested!!!):
<?php
add_action('init', 'add_my_rewrite');
function add_my_rewrite() {
global $wp_rewrite;
$wp_rewrite->add_rule('location/([^/]+)/code/([^/]+)','index.php?loc=$matches[1]&code=$matches[2]','top');
$wp_rewrite->flush_rules(false); // This should really be done in a plugin activation
}
This should add the rewrite structure to your .htaccess file automatically.