make laravel 5 generate seo friendly url after submit - php

I am using laravel 5.2 and I have search form which pass GET parameter, so in url its like
http://www.example.com/list/item?&qs=&unit-type=Office&min-bed=&max-bed=&min-price=&max-price=
so search result is shown with such ugly url, I want to make this url seo friendly, I don't want to use post method.
Is there any .htaccess code that can help to make seo friendly url of such get parameter.
I tried this .htaccess code but doesn't work.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?params=$1 [L,QSA]

What you are doing is possible, but shouldn't be done.
The page is not a static page, or a product page, or a listing page. It is a search result page.
The search result page should not be SEO friendly in terms of the url containing information about the search query because this is supposed to be dynamic. A search engine will not be interested in indexing a specific user's search result page on your website. A search engine will be interested in indexing the search page.
If you are looking to have a product listing page for example with pre-defined search queries, then why not just create a specific controller and for the time being, manually write an SEO friendly url to point to the required method on that controller?
e.g.
Route::get('offices-between-10000-and-20000-pounds', 'ListingController#getOfficesBetweenPriceRange');

Related

How to get my CMS System work with SEO friendly URLs

i got a question abount seo friendly urls.
Manly, i would like to know whats the best way to get my system running with seo friendly urls. i have programmed my own cms system which is working at the moment with url like this:
/content.php?contentid=ID
On every content page you can change the Meta-Tags.
Every LINK which is generated in my CMS follows this structure. If i want to use SEO friendly URLs changing every link, or code, where a link is generated, might be a bad idea. So i am looking for a nicer way. Is there any commonly used way to handle this?
My first idea was to automatically generate a new .htacces file with ModRewrite after the MetaTags of a Contentfile have been changed. So the SEO friendly URLs are recognized by the system. To get the LINKs on every page working i was thinking about checking the current url and redirecting to the new seo friendly url at the beginning of the content.php file.
I dont know if this is the right way to work with seo friendly urls. How are other CMS Systems handling this issue? I would be thankful for any inspiration!
if you are using an framework(which i think you are) then you can use a .htaccess like this to send the new cleaner links in an $_GET to the framework:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

Rewriting php urls to produce clean urls .htaccess

I'm using a custom built CMS and I need to rewrite the urls because currently they take the page ID and name of the page into the url.
/pages/1411760825/Facilities is an example of the current url
/Facilities is what I want it to show up as in the URL bar
The pages are linking to each other based on their ids and titles and I want it to not do that anymore.
This is the current .htaccess rule
RewriteEngine on
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]
I know I need to add a line below to rewrite what I want it to be, but I'm unsure how to achieve this.

SEO : what to do after url re writing

I've made my php website url fiendly with url re-writting as,
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[A-Za-z0-9-_]+/([A-Za-z0-9-_]+)/?$ product.php?uni_id=$1 [NC,L] #
So, Old urls were,
http://example.com/product.php&uni_id=laptop-123
and new url is,
http://example.com/products/laptop-123/
Now, When search engine comes back they should informed about (old url is permenently moved to) new url or i can remove all entries from search engines in order to get rid of duplicate entries in search engines.
Now, what i have to do after writing url in terms of seo purpose.
NOTE : I've heard about using 301 redirects but don't know how to implement it.
To improve your SEO you should add canonical URLs.
You do that by adding a canonical url in the head of the page in question, so in your example:
<link rel="canonical" href="http://example.com/products/laptop-123/">
That way for example Google knows which url to index and it will not penalize you for duplicate content.
Note that this is only one of the (easiest...) ways to achieve this, you could for example also do a 301 redirect when a visitor is not using your preferred url.
Also see the information from Google itself.

Wordpress pretty permalinks /w Pretty query parameters (For sort) via ModRewrite

I currently have wordpress pages that that can be viewed via both the index page (all the posts) and also the category pages.
My current permalink structure is 'http://www.mysite.com/%postname%/' which is neat and i would like to keep.
Current examples..
Home page (post list)
http://www.mysite.com/
Category page (filtered post list - filter on category)
http://www.mysite.com/categoryname/
Any post list needs to be order (by choice of the user) by any of the following parameters...
Oldest->Newest , Newest->Oldest , Expensive->Cheapest , Cheapest->Expensive , HighestRated->LowestRated , LowestRated->HighestRated
I have handled all the sorting correctly in the functions.php and it retrieves from from GET parameter set. (the last 4 are custom meta attributes which I have sorted/handled correctly)
Examples are...
http://www.mysite.com?SortBy=Newest
http://www.mysite.com/categoryname?SortBy=HighestRated
I can't get a correct functioning .htaccess file with ModRewrite that achieves this....
I would like them to look like these (for the 2 examples above)
http://www.mysite.com/SortBy/Newest/
http://www.mysite.com/categoryname/SortBy/HighestRated
My webserver is running Apache on Linux server.
My current .htaccess file looks like this...
# 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
It doesn't seem to be doing my current re-write actions but I presume these are handled by Wordpress elsewhere??
Use the add_query_arg WordPress function. WordPress is designed to reject any URL query parameters that it doesn’t recognize. You will need to tell WordPress about the new parameter(s) you will be sending via a URL.
Reference:
http://codex.wordpress.org/Function_Reference/add_query_arg
"Retrieve a modified URL (with) query string.
You can rebuild the URL and append a new query variable to the URL query by using this function. You can also retrieve the full URL with query data."

How to load Hard Coded Pages with CMS values using PHP?

Let me explain the scenario first.
I have built a cms in which I load every page on one page like this.
http://www.mywebsite.com/index.php?page=about
Here "about" is a slug of the page I create from the Cms.
So the sql query fetch the record using the slug & retrieve the content of the page & print it on index.php
Now the next thing I have done is, I have done URL rewriting in .htaccess file like below
Options +FollowSymlinks RewriteEngine On
RewriteCond %{REQUEST_URI} !^.(images/|.js|.css).$ [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ /index.php?page=$1
So now I can use this kind of URLs on my site for same "about" page
http://www.mywebsite.com/about
Now the Question is, these all pages are simply content based, but how should I maintain Dynamic pages.
E.g. I have a page for Member Registration as signup.php
I want to assign all the title, heading, meta desc, meta keywords from CMS to this page but also want to load this page using
http://www.mywebsite.com/signup.php
& not like
http://www.mywebsite.com/signup
What kind of logic should I apply to load the page as signup.php & also fetch the CMS values ?
One solution I have in mind is, we should put one more field in CMS as "Code File :" & enter signup.php over there. But still I am not sure.
Add another rewrite condition which forces it to not redirect to index.php:
RewriteCond %{REQUEST_URI} !\.php$ [NC]

Categories