I have a bilingual wordpress site that adds the language subdomain into the URL (e.g., mysite.com/en/first-page/. I am trying to find a simple way (can it be done via the functions.php file?) to rewrite the URL to have it remove the /en/, making the URL mysite.com/first-page/. Is this possible? I've looked at some tuts and a lot of them focus on stuff like archives and categories and I'm not sure they can help me.
Since you asked for a functions.php solution, you may be able to use add_rewrite_rule(). Something like:
add_rewrite_rule('^first-page/?', 'en/first-page/');
If that doesn't work, you should consider adding a rule to .htaccess.
Related
i have tried to load a flat panel write on PHP i put in a wordpress theme.
for alone the script run great but i want run that on wordpress theme.
problem in them routing. for example:
site/wp-content/themes/admin/dashboard/
site/wp-content/themes/admin/dashboard/sprofile
site/wp-content/themes/admin/dashboard/rprofile
can not access above route.
i think this solve with .htaccess file but don't know how !?
is there any way?!
If you're using wordpress you may want to create a shortcode for your script but, in case you don't want to, you can also use .htaccess with the rewrite module to redirect a url and access your panel.
Here are two examples that I hope will help you:
.htaccess rewrite examples
Shortcode examples
If I understood your situation correctly, you want to run a piece of PHP code which prints stuff inside the page as a feature in your WP theme. Not knowing the details, i can give you a couple of ideas:
If you need to embed that in an existing page (or s a new page itself), you need to create a template/template part and manage it trough wordpress's apis (which includes, as said, shipping it as a template part or a template itself, See codex)
If you need to create a new page with custom logic which is more suitable to be written as a plugin, consider adding a rewrite rule to a custom route (See this section of the codex and take a look at this article)
that is i want
when enter to
site/wp-content/themes/admin/dashboard/login
rewrite to
site/wp-content/themes/admin/dashboard/?url=login
login not static
now i use this to htaccess but don't work :
RewriteRule ^wp-content/themes/bluetheme/dashboard/(.*)$ /subdirectory/wp-content/themes/bluetheme/dashboard?url=$1 [L,NC,QSA]
Don't try cheating on WP, by smuggling your php file in some dir and trying to call it from there, by tweaking .htaccess file and similar. Look for system way to create custom WP page. I.e.
https://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/
I have a question about rewrite rules and WordPress permalinks. For the purposes of a localisation feature, I need to prepend a 'pretty' param at the beginning of all paths on a site. So for example, example.com/post-title would become example.com/en/post-title. To do this I was thinking of creating a rewrite rule in the .htaccess which would take a ?lang=en from the end of the url and transform it as described. Is this even possible with rewrite rules? And even if it is, would the permalinks in WP honour it or would they just revert to the link stored in the db for the post?
I would recommend using WPML or another plugin like this to work with different languages in WordPress. WPML will also solve your 'pretty' URL problem without rewrite etc.
i am trying to change the wordpress url with htaccess, i have the following scenario
My url will look like this, this will be visible to users.
http://www.example.com/custom-field-name1/custom-field2/post-name
While the actual url is this one
http://www.example.com/post-type-name/post-name.
Please help me how this will be possible with htaccess
I guess you require custom permalinks.
Using which you can change your permalink structure as you require with custom fields.
Kindly go through the following to know in depth
http://www.wpbeginner.com/wp-tutorials/how-to-create-custom-permalinks-in-wordpress/
Hope this helps you mate
Edit :
As per my suggestion htaccess is not necessary for this.
How do I remove ?title= in Main Website url in Wordpress
Sample URL:
http://mydomain.com/propertiesdetail?title=this-is-title
Please Help. Thank you.
As far as I can understand you want to have 'nice' URLs.
Wordpress has built-in SEO and user-friendly URL rewrite implementation. All you have to do is check your Permalinks settings in Administration area->Settings.
Select to use not the Default, but Post name (or anything else, you can see all the options). This way all website URLs will be 'beautified' automatically, because Wordpress will rewrite the .htaccess file with the correct code.
I have a WordPress blog. All the post are currently in this convention:
http://www.myblog.com/blog/?p=1442
Now I'd like to change the URL of all posts like this one:
http://www.gomidjets.com/blog/this-is-my-post
While it's quite easy to apply it by changing the blog settings, the big problem is about the links I've placed
in many external website. I can't change them, and I'd like to map the old links to the new links somehow.
Do you know how to do it - if that's possible at all?
Do you have a better solution?
Thank you very much
Wordpress will map all old URL to new one, in case if you provided all URL in their original shape, such as http://example.com/?page_id=80
The answer is: you don't need to do anything.
I believe what you're looking for can be found in the admin panel.
In the admin panel (http://www.your-wordpress-site.com/wp-admin), go to Settings > Permalinks
Login to the admin panel first,
go for the settings->Permalink Settings
Select the format you want.
If you want change the base url for only some posts then you can edit from database.
Try this Redirection wordpress plugin to redirect your old url to your new url.
The URL's should resolve fine because the original URL you're using is the permalink one to my knowledge. If you're wanting end users to be redirected to this url, that's a bit harder.
That aside, I couldn't find any plugins that already did this. What you want to do is check the current URL against the wordpress function get_permalink() and if it doesn't match, redirect to the current permalink URL.