SEO friendly URL parameters via .htaccess - php

I want to rewrite the URLs from:
https://www.example.com/bibliorafturi/?wpsolr_fq%5B0%5D=pa_culoare_str%3AAlbastru
to this:
https://www.example.com/bibliorafturi/Albastru
Another example:
https://www.example.com/bibliorafturi/?wpsolr_fq%5B0%5D=pa_culoare_str%3AAlbastru&wpsolr_fq%5B1%5D=pa_brand_str%3AESSELTE
to this
https://www.example.com/bibliorafturi/Albastru/?wpsolr_fq%5B1%5D=pa_brand_str%3AESSELTE
So I need only pa_culoare_str to be SEO friendly.
How can I do this with .htaccess?
UPDATE:
This is my .htaccess file now:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} /(.*)/(.*)/(.*)/?$
RewriteRule ^ /%1?wpsolr_fq[%3]=pa_culoare_str:%2 [QSA,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Thank you!

Related

Needed htaccess rewrite to preserve migration to wordpress

I have a website with this kind of querystring:
http://www.example.com/index.php?action=show&id=4577
I am moving to wordpress with this blog format:
http://www.example.com/archives/4577
But i should preserve wordpress rewrite conditions
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This solution worked for me (i realized by my own...):
RewriteCond %{QUERY_STRING} action=show&id=([0-9]+)$
RewriteRule .*$ /archives/%1? [NC,R,L]

URL rewriting with Wordpress Rewrite or .htaccess

I'm trying to append to wordpress an additional parameter into my URL.
For example, I have the URL: http://example.com
I want to change that to URL: http://example.com/this-example/
I'm thinking I can do this is in htaccess along the lines of a rewrite condition, but i'm unsure how to go about this. This is what I was thinking here.
Htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine on
RewriteRule ^/this-example/(.*)/ /index.php?$1 [L]
</IfModule>
Options -Indexes
You can try this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{THE_REQUEST} !^/this-example [NC]
# use your own host here, for me is 192.68.10.10
RewriteCond %{HTTP_HOST} 192\.168\.10\.10$ [NC]
RewriteRule !^this-example/ /this-example%{REQUEST_URI} [L,R,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^this-example/(.*)$ $1 [L,QSA]
</IfModule>
Options -Indexes

.htaccess doesnt take the rewrite rule

i have a problem with the htaccess file from a system which i bought.
The Original 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>
My modified version looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^city-([^/]+).html searcharea?city=$1&sd=ls [L]
RewriteRule ^city-normal-([^/]+).html searcharea?city=$1&sd=pb [L]
RewriteRule ^city-special-([^/]+).html searcharea?city=$1&sd=oeb [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The Systems Base Home Link looks like this:
http://www.url.de/store/home
and my .htaccess is completely ignored, i wonder why?
i want to include a seo linking to the system and reffer its url to the function but it doesnt work with this htaccess.
i have this htaccess rules in my other htaccess file from another system and there it works perfectly.
edit:
the rules from original file work, just my rules are ignored. mod_rewrite is enabled
Structure of my dirs:
/
/.htaccess
/index.php -> uses yiiframework to build pages
/core
/core/css
/core/js
This is because your orignal htaccess rules are conflicting with the new rules and they rewrite all non existent requests to index.php. To fix this, you need to reorder your rules .
Try :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^city-([^/]+).html searcharea?city=$1&sd=ls [L]
RewriteRule ^city-normal-([^/]+).html searcharea?city=$1&sd=pb [L]
RewriteRule ^city-special-([^/]+).html searcharea?city=$1&sd=oeb [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Make sure that mod_rewrite is enabled in apache on your server.

404 error not work for /%post_id%/%postname%.html

i use /%post_id%/%postname%.html in my wordpress permalink.
404 eror dont work for this permalink if post or page not exist.
but for another link 404 work good.
this is my htaccess file :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
thanks for your help.
Check this might be help you
set apache to "AllowOverride All"
mod_rewrite is present, .htaccess looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wikiarr_prd/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wikiarr_prd/index.php [L]
</IfModule>
# END WordPress
Permalinks structure:
/%postname%_%post_id%.html

htaccess rewrite url rule

I'm new to htaccess and I need some help with a rewrite rule.
I wish to rewrite:
/all-accomodation/anything/ to: /portfolio-gallery/anything/
The 'anything' could be any slug.
One thing to note is that I have a page with a slug of 'all-accomodation' and when requested by itself shouldn't rewrite.
Here is my current htaccess file:
# 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
Thanks in advance,
Dave
You don't want to edit Wordpress's rewrite. Above that block, you can try:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^all-accomodation/(.+)(/?) /portfolio-gallery/$1$2 [L]
</IfModule>
This will 301 redirect all requests.

Categories